email_direct 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
data/.gitignore ADDED
@@ -0,0 +1,3 @@
1
+ pkg/*
2
+ *.gem
3
+ .bundle
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source "http://rubygems.org"
2
+
3
+ # Specify your gem's dependencies in email_direct.gemspec
4
+ gemspec
data/Gemfile.lock ADDED
@@ -0,0 +1,41 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ email_direct (0.0.1)
5
+ activesupport (~> 3.0.0)
6
+ builder (~> 2.1.2)
7
+ nokogiri (= 1.4.1)
8
+ serviceproxy (~> 0.2.1)
9
+
10
+ GEM
11
+ remote: http://rubygems.org/
12
+ specs:
13
+ activesupport (3.0.1)
14
+ builder (2.1.2)
15
+ diff-lcs (1.1.2)
16
+ hpricot (0.8.2)
17
+ nokogiri (1.4.1)
18
+ rspec (2.0.1)
19
+ rspec-core (~> 2.0.1)
20
+ rspec-expectations (~> 2.0.1)
21
+ rspec-mocks (~> 2.0.1)
22
+ rspec-core (2.0.1)
23
+ rspec-expectations (2.0.1)
24
+ diff-lcs (>= 1.1.2)
25
+ rspec-mocks (2.0.1)
26
+ rspec-core (~> 2.0.1)
27
+ rspec-expectations (~> 2.0.1)
28
+ serviceproxy (0.2.1)
29
+ hpricot
30
+ nokogiri
31
+
32
+ PLATFORMS
33
+ ruby
34
+
35
+ DEPENDENCIES
36
+ activesupport (~> 3.0.0)
37
+ builder (~> 2.1.2)
38
+ email_direct!
39
+ nokogiri (= 1.4.1)
40
+ rspec (~> 2.0.0)
41
+ serviceproxy (~> 0.2.1)
data/MIT-LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ Copyright (c) 2010 Tucker Connelly, wynst
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
21
+
data/README.md ADDED
@@ -0,0 +1,38 @@
1
+ # Email Direct API
2
+
3
+ Ruby wrapper for [emaildirect.com](http://emaildirect.com) SOAP service
4
+
5
+ To use this gem, initialize with your account name and password. All the SOAP calls (found here: http://dev.emaildirect.com/v1/) are functions of the module with the same function name and parameters (minus the credentials). This gem depends on the serviceproxy and activesupport gems.
6
+
7
+ ## Installation
8
+
9
+ gem install email_direct
10
+
11
+ ## Usage
12
+
13
+ require 'email_direct'
14
+
15
+ username = 'username'
16
+ password = 'password'
17
+
18
+ @soap = EmailDirect::SOAP.new(username, password)
19
+ #uncomment this line for full debug info
20
+ #@soap.debug = true
21
+
22
+ element_name = 'RubyTestSource2'
23
+ description = 'a test source item'
24
+
25
+ result = @soap.Source_Add("ElementName" => element_name, "Description" => element_name)
26
+ puts "Error Adding source " unless result.success?
27
+
28
+ result = @soap.Source_GetAll()
29
+ source = result.data["Element"].find {|e| e["ElementName"] == element_name}
30
+ pp source
31
+
32
+ puts "we're done with the test, delete the test source"
33
+ result = @soap.Source_Delete("SourceID" => source["ElementID"])
34
+
35
+ ## TODO
36
+
37
+ More specs
38
+
data/Rakefile ADDED
@@ -0,0 +1,2 @@
1
+ require 'bundler'
2
+ Bundler::GemHelper.install_tasks
@@ -0,0 +1,27 @@
1
+ # -*- encoding: utf-8 -*-
2
+ $:.push File.expand_path("../lib", __FILE__)
3
+ require "email_direct/version"
4
+
5
+ Gem::Specification.new do |s|
6
+ s.name = "email_direct"
7
+ s.version = EmailDirect::VERSION
8
+ s.platform = Gem::Platform::RUBY
9
+ s.authors = ["Tucker Connelly", "wynst"]
10
+ s.email = ["l4nc3r@comcast.net", "wynst.uei@gmail.com"]
11
+ s.homepage = "http://rubygems.org/gems/email_direct"
12
+ s.summary = %q{Used to connect to the EmailDirect SOAP service.}
13
+ s.description = %q{To use this gem, initialize with your account name and password. All the SOAP calls (found here: http://dev.emaildirect.com/v1/) are functions of the module with the same function name and parameters (minus the credentials). This gem depends on the serviceproxy and activesupport gems.}
14
+
15
+ s.rubyforge_project = "email_direct"
16
+
17
+ s.files = `git ls-files`.split("\n")
18
+ s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
19
+ s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
20
+ s.require_paths = ["lib"]
21
+ s.add_dependency "serviceproxy", "~> 0.2.1"
22
+ s.add_dependency "nokogiri", "= 1.4.1"
23
+ s.add_dependency "builder", "~> 2.1.2"
24
+ s.add_dependency "activesupport", "~> 3.0.0"
25
+ s.add_development_dependency "rspec", "~> 2.0.0"
26
+ end
27
+
data/examples/email.rb ADDED
@@ -0,0 +1,53 @@
1
+ require 'email_direct'
2
+
3
+ username = 'username'
4
+ password = 'password'
5
+
6
+ @soap = EmailDirect::SOAP.new(username, password)
7
+ #uncomment this line for full debug info
8
+ #@soap.debug = true
9
+
10
+ result = @soap.Source_GetAll()
11
+ source_id = result.data["Element"].first["ElementID"]
12
+
13
+ # create some publication
14
+ @soap.Publication_Add("ElementName" => "Publication1", "Description" => "publication 1 info")
15
+ @soap.Publication_Add("ElementName" => "Publication2", "Description" => "publication 2 info")
16
+
17
+ result = @soap.Publication_GetAll()
18
+ publication_id1 = result.data["Element"][0]["ElementID"]
19
+ publication_id2 = result.data["Element"][1]["ElementID"]
20
+
21
+ # create some list
22
+ result = @soap.List_Add("ElementName" => "List1", "Description" => "List 1 info")
23
+ result = @soap.List_Add("ElementName" => "List2", "Description" => "List 2 info")
24
+
25
+ result = @soap.List_GetAll()
26
+ list_id1 = result.data["Element"][0]["ElementID"]
27
+ list_id2 = result.data["Element"][1]["ElementID"]
28
+
29
+ result = @soap.Email_AddWithFields(
30
+ "Email" => "someone@test.com",
31
+ "SourceID" => source_id,
32
+ "Publications" => [
33
+ {"int" => publication_id1},
34
+ {"int" => publication_id2}
35
+ ],
36
+ "Lists" => [
37
+ {"int" => list_id1},
38
+ {"int" => list_id2}
39
+ ],
40
+ "AutoResponderID" => 0,
41
+ "Force" => "false",
42
+ "CustomFields" => [
43
+ {
44
+ "FieldName" => "FirstName",
45
+ "Value" => "Jason"
46
+ }, {
47
+ "FieldName" => "LastName",
48
+ "Value" => "Red"
49
+ }
50
+ ])
51
+
52
+ puts result.message
53
+
@@ -0,0 +1,26 @@
1
+ require 'email_direct'
2
+
3
+ username = 'username'
4
+ password = 'password'
5
+
6
+ @soap = EmailDirect::SOAP.new(username, password)
7
+ #uncomment this line for full debug info
8
+ #@soap.debug = true
9
+
10
+ puts "creating new source.."
11
+
12
+ element_name = 'RubyTestSource2'
13
+ description = 'a test source item'
14
+
15
+ result = @soap.Source_Add("ElementName" => element_name, "Description" => element_name)
16
+ puts result.message
17
+
18
+ result = @soap.Source_GetAll()
19
+
20
+ source = result.data["Element"].find {|e| e["ElementName"] == element_name}
21
+ pp source
22
+
23
+
24
+ puts "we're done with the test, delete the test source"
25
+ result = @soap.Source_Delete("SourceID" => source["ElementID"])
26
+
@@ -0,0 +1,6 @@
1
+ require 'email_direct/soap'
2
+
3
+ module EmailDirect
4
+ # Your code goes here...
5
+ end
6
+
@@ -0,0 +1,40 @@
1
+ module EmailDirect
2
+ class Response
3
+ attr_reader :xml, :code, :message, :data
4
+
5
+ def initialize(xml)
6
+ @xml = xml
7
+ parse_response!
8
+ end
9
+
10
+ def success?
11
+ @code == 0
12
+ end
13
+
14
+ private
15
+ def parse_response!
16
+ doc = Nokogiri::XML(@xml)
17
+ elem = doc.xpath("//*[contains(name(),'Result')]", 'xpath' => 'http://espapi.net/v1/components/apiresult')
18
+ if elem.length == 1
19
+ #bug in Nokogiri?
20
+ #@code = elem.css("Code").first.inner_text.to_i
21
+ #@message = elem.css("Message").first.inner_text
22
+ found = 0
23
+ elem.children.each do |node|
24
+ case node.name
25
+ when 'Code' then found+=1; @code = node.inner_text.to_i;
26
+ when 'Message' then found+=1; @message = node.inner_text;
27
+ end
28
+ end
29
+ if found != 2
30
+ @code = 0
31
+ @data = Hash.from_xml(elem.first.to_xml)
32
+ #ignore wrapping element (eg. Source_GetAllResult)
33
+ @data = @data[@data.keys.first]
34
+ end
35
+ end
36
+ end
37
+
38
+ end
39
+ end
40
+
@@ -0,0 +1,11 @@
1
+ module EmailDirect
2
+ module ServiceProxyPatch
3
+ # same as original, but don't call .target! on custom builder
4
+ def build_request(method, options)
5
+ builder = underscore("build_#{method}")
6
+ self.respond_to?(builder) ? self.send(builder, options) :
7
+ soap_envelope(options).target!
8
+ end
9
+ end
10
+ end
11
+
@@ -0,0 +1,891 @@
1
+ require 'nokogiri'
2
+ require 'service_proxy/base'
3
+ require 'email_direct/service_proxy_patch'
4
+ require 'active_support/core_ext/hash/conversions'
5
+ ActiveSupport::XmlMini.backend = 'Nokogiri'
6
+ require 'email_direct/response'
7
+
8
+ module EmailDirect
9
+ class SOAP < ServiceProxy::Base
10
+ include ServiceProxyPatch
11
+ attr_accessor :credentials
12
+
13
+ def initialize(accountname, password, options={})
14
+ super(options["EndPoint"] || "http://espapi.net/v1/api.asmx?WSDL")
15
+ @credentials = {}
16
+ @credentials["AccountName"] = accountname
17
+ @credentials["Password"] = password
18
+ @credentials["Enc"] = options["Enc"] || options[:enc]
19
+ end
20
+
21
+ def build_account_get_active_emails(options)
22
+ email_direct_envelope(options) do |xml|
23
+ end
24
+ end
25
+
26
+ def parse_account_get_active_emails(response)
27
+ ::EmailDirect::Response.new(response.body)
28
+ end
29
+
30
+ def build_account_get_active_emails_simple(options)
31
+ email_direct_envelope(options) do |xml|
32
+ end
33
+ end
34
+
35
+ def parse_account_get_active_emails_simple(response)
36
+ ::EmailDirect::Response.new(response.body)
37
+ end
38
+
39
+ def build_account_get_complaints(options)
40
+ email_direct_envelope(options) do |xml|
41
+ end
42
+ end
43
+
44
+ def parse_account_get_complaints(response)
45
+ ::EmailDirect::Response.new(response.body)
46
+ end
47
+
48
+ def build_account_get_complaints_simple(options)
49
+ email_direct_envelope(options) do |xml|
50
+ end
51
+ end
52
+
53
+ def parse_account_get_complaints_simple(response)
54
+ ::EmailDirect::Response.new(response.body)
55
+ end
56
+
57
+ def build_account_get_database_fields(options)
58
+ email_direct_envelope(options) do |xml|
59
+ end
60
+ end
61
+
62
+ def parse_account_get_database_fields(response)
63
+ ::EmailDirect::Response.new(response.body)
64
+ end
65
+
66
+ def build_account_get_global_removes(options)
67
+ email_direct_envelope(options) do |xml|
68
+ end
69
+ end
70
+
71
+ def parse_account_get_global_removes(response)
72
+ ::EmailDirect::Response.new(response.body)
73
+ end
74
+
75
+ def build_account_get_global_removes_simple(options)
76
+ email_direct_envelope(options) do |xml|
77
+ end
78
+ end
79
+
80
+ def parse_account_get_global_removes_simple(response)
81
+ ::EmailDirect::Response.new(response.body)
82
+ end
83
+
84
+ def build_account_get_hard_bounces(options)
85
+ email_direct_envelope(options) do |xml|
86
+ end
87
+ end
88
+
89
+ def parse_account_get_hard_bounces(response)
90
+ ::EmailDirect::Response.new(response.body)
91
+ end
92
+
93
+ def build_account_get_hard_bounces_simple(options)
94
+ email_direct_envelope(options) do |xml|
95
+ end
96
+ end
97
+
98
+ def parse_account_get_hard_bounces_simple(response)
99
+ ::EmailDirect::Response.new(response.body)
100
+ end
101
+
102
+ def build_account_get_ip_information(options)
103
+ email_direct_envelope(options) do |xml|
104
+ end
105
+ end
106
+
107
+ def parse_account_get_ip_information(response)
108
+ ::EmailDirect::Response.new(response.body)
109
+ end
110
+
111
+ def build_account_set_email_limit(options)
112
+ email_direct_envelope(options) do |xml|
113
+ end
114
+ end
115
+
116
+ def parse_account_set_email_limit(response)
117
+ ::EmailDirect::Response.new(response.body)
118
+ end
119
+
120
+ def build_campaign_add(options)
121
+ email_direct_envelope(options) do |xml|
122
+ end
123
+ end
124
+
125
+ def parse_campaign_add(response)
126
+ ::EmailDirect::Response.new(response.body)
127
+ end
128
+
129
+ def build_campaign_copy(options)
130
+ email_direct_envelope(options) do |xml|
131
+ end
132
+ end
133
+
134
+ def parse_campaign_copy(response)
135
+ ::EmailDirect::Response.new(response.body)
136
+ end
137
+
138
+ def build_campaign_get_clicks(options)
139
+ email_direct_envelope(options) do |xml|
140
+ end
141
+ end
142
+
143
+ def parse_campaign_get_clicks(response)
144
+ ::EmailDirect::Response.new(response.body)
145
+ end
146
+
147
+ def build_campaign_get_clicks_for_link(options)
148
+ email_direct_envelope(options) do |xml|
149
+ end
150
+ end
151
+
152
+ def parse_campaign_get_clicks_for_link(response)
153
+ ::EmailDirect::Response.new(response.body)
154
+ end
155
+
156
+ def build_campaign_get_complaints(options)
157
+ email_direct_envelope(options) do |xml|
158
+ end
159
+ end
160
+
161
+ def parse_campaign_get_complaints(response)
162
+ ::EmailDirect::Response.new(response.body)
163
+ end
164
+
165
+ def build_campaign_get_hard_bounces(options)
166
+ email_direct_envelope(options) do |xml|
167
+ end
168
+ end
169
+
170
+ def parse_campaign_get_hard_bounces(response)
171
+ ::EmailDirect::Response.new(response.body)
172
+ end
173
+
174
+ def build_campaign_get_list_drafts(options)
175
+ email_direct_envelope(options) do |xml|
176
+ end
177
+ end
178
+
179
+ def parse_campaign_get_list_drafts(response)
180
+ ::EmailDirect::Response.new(response.body)
181
+ end
182
+
183
+ def build_campaign_get_list_scheduled(options)
184
+ email_direct_envelope(options) do |xml|
185
+ end
186
+ end
187
+
188
+ def parse_campaign_get_list_scheduled(response)
189
+ ::EmailDirect::Response.new(response.body)
190
+ end
191
+
192
+ def build_campaign_get_list_sent(options)
193
+ email_direct_envelope(options) do |xml|
194
+ end
195
+ end
196
+
197
+ def parse_campaign_get_list_sent(response)
198
+ ::EmailDirect::Response.new(response.body)
199
+ end
200
+
201
+ def build_campaign_get_opens(options)
202
+ email_direct_envelope(options) do |xml|
203
+ end
204
+ end
205
+
206
+ def parse_campaign_get_opens(response)
207
+ ::EmailDirect::Response.new(response.body)
208
+ end
209
+
210
+ def build_campaign_get_recipients(options)
211
+ email_direct_envelope(options) do |xml|
212
+ end
213
+ end
214
+
215
+ def parse_campaign_get_recipients(response)
216
+ ::EmailDirect::Response.new(response.body)
217
+ end
218
+
219
+ def build_campaign_get_removes(options)
220
+ email_direct_envelope(options) do |xml|
221
+ end
222
+ end
223
+
224
+ def parse_campaign_get_removes(response)
225
+ ::EmailDirect::Response.new(response.body)
226
+ end
227
+
228
+ def build_campaign_get_summary(options)
229
+ email_direct_envelope(options) do |xml|
230
+ end
231
+ end
232
+
233
+ def parse_campaign_get_summary(response)
234
+ ::EmailDirect::Response.new(response.body)
235
+ end
236
+
237
+ def build_campaign_schedule(options)
238
+ email_direct_envelope(options) do |xml|
239
+ end
240
+ end
241
+
242
+ def parse_campaign_schedule(response)
243
+ ::EmailDirect::Response.new(response.body)
244
+ end
245
+
246
+ def build_creative_add(options)
247
+ email_direct_envelope(options) do |xml|
248
+ end
249
+ end
250
+
251
+ def parse_creative_add(response)
252
+ ::EmailDirect::Response.new(response.body)
253
+ end
254
+
255
+ def build_creative_create_folder(options)
256
+ email_direct_envelope(options) do |xml|
257
+ end
258
+ end
259
+
260
+ def parse_creative_create_folder(response)
261
+ ::EmailDirect::Response.new(response.body)
262
+ end
263
+
264
+ def build_creative_get_creatives_for_folder(options)
265
+ email_direct_envelope(options) do |xml|
266
+ end
267
+ end
268
+
269
+ def parse_creative_get_creatives_for_folder(response)
270
+ ::EmailDirect::Response.new(response.body)
271
+ end
272
+
273
+ def build_creative_get_folders(options)
274
+ email_direct_envelope(options) do |xml|
275
+ end
276
+ end
277
+
278
+ def parse_creative_get_folders(response)
279
+ ::EmailDirect::Response.new(response.body)
280
+ end
281
+
282
+ def build_email_add(options)
283
+ email_direct_envelope(options) do |xml|
284
+ end
285
+ end
286
+
287
+ def parse_email_add(response)
288
+ ::EmailDirect::Response.new(response.body)
289
+ end
290
+
291
+ def build_email_add_with_fields(options)
292
+ email_direct_envelope(options) do |xml|
293
+ #adjustments for activesupport list hash to EmailDirect specific xml
294
+ xml.gsub!("<List>\n","")
295
+ xml.gsub!("</List>\n","")
296
+ xml.gsub!("<Publication>\n","")
297
+ xml.gsub!("</Publication>\n","")
298
+ end
299
+ end
300
+
301
+ def parse_email_add_with_fields(response)
302
+ ::EmailDirect::Response.new(response.body)
303
+ end
304
+
305
+ def build_email_add_simple(options)
306
+ email_direct_envelope(options) do |xml|
307
+ end
308
+ end
309
+
310
+ def parse_email_add_simple(response)
311
+ ::EmailDirect::Response.new(response.body)
312
+ end
313
+
314
+ def build_email_change(options)
315
+ email_direct_envelope(options) do |xml|
316
+ end
317
+ end
318
+
319
+ def parse_email_change(response)
320
+ ::EmailDirect::Response.new(response.body)
321
+ end
322
+
323
+ def build_email_delete(options)
324
+ email_direct_envelope(options) do |xml|
325
+ end
326
+ end
327
+
328
+ def parse_email_delete(response)
329
+ ::EmailDirect::Response.new(response.body)
330
+ end
331
+
332
+ def build_email_delete_simple(options)
333
+ email_direct_envelope(options) do |xml|
334
+ end
335
+ end
336
+
337
+ def parse_email_delete_simple(response)
338
+ ::EmailDirect::Response.new(response.body)
339
+ end
340
+
341
+ def build_email_get_history(options)
342
+ email_direct_envelope(options) do |xml|
343
+ end
344
+ end
345
+
346
+ def parse_email_get_history(response)
347
+ ::EmailDirect::Response.new(response.body)
348
+ end
349
+
350
+ def build_email_get_properties(options)
351
+ email_direct_envelope(options) do |xml|
352
+ end
353
+ end
354
+
355
+ def parse_email_get_properties(response)
356
+ ::EmailDirect::Response.new(response.body)
357
+ end
358
+
359
+ def build_email_remove(options)
360
+ email_direct_envelope(options) do |xml|
361
+ end
362
+ end
363
+
364
+ def parse_email_remove(response)
365
+ ::EmailDirect::Response.new(response.body)
366
+ end
367
+
368
+ def build_email_remove_simple(options)
369
+ email_direct_envelope(options) do |xml|
370
+ end
371
+ end
372
+
373
+ def parse_email_remove_simple(response)
374
+ ::EmailDirect::Response.new(response.body)
375
+ end
376
+
377
+ def build_email_update(options)
378
+ email_direct_envelope(options) do |xml|
379
+ end
380
+ end
381
+
382
+ def parse_email_update(response)
383
+ ::EmailDirect::Response.new(response.body)
384
+ end
385
+
386
+ def build_filter_get_all(options)
387
+ email_direct_envelope(options) do |xml|
388
+ end
389
+ end
390
+
391
+ def parse_filter_get_all(response)
392
+ ::EmailDirect::Response.new(response.body)
393
+ end
394
+
395
+ def build_filter_get_subscribers(options)
396
+ email_direct_envelope(options) do |xml|
397
+ end
398
+ end
399
+
400
+ def parse_filter_get_subscribers(response)
401
+ ::EmailDirect::Response.new(response.body)
402
+ end
403
+
404
+ def build_filter_get_subscribers_simple(options)
405
+ email_direct_envelope(options) do |xml|
406
+ end
407
+ end
408
+
409
+ def parse_filter_get_subscribers_simple(response)
410
+ ::EmailDirect::Response.new(response.body)
411
+ end
412
+
413
+ def build_list_add(options)
414
+ email_direct_envelope(options) do |xml|
415
+ end
416
+ end
417
+
418
+ def parse_list_add(response)
419
+ ::EmailDirect::Response.new(response.body)
420
+ end
421
+
422
+ def build_list_delete(options)
423
+ email_direct_envelope(options) do |xml|
424
+ end
425
+ end
426
+
427
+ def parse_list_delete(response)
428
+ ::EmailDirect::Response.new(response.body)
429
+ end
430
+
431
+ def build_list_get_all(options)
432
+ email_direct_envelope(options) do |xml|
433
+ end
434
+ end
435
+
436
+ def parse_list_get_all(response)
437
+ ::EmailDirect::Response.new(response.body)
438
+ end
439
+
440
+ def build_list_get_members(options)
441
+ email_direct_envelope(options) do |xml|
442
+ end
443
+ end
444
+
445
+ def parse_list_get_members(response)
446
+ ::EmailDirect::Response.new(response.body)
447
+ end
448
+
449
+ def build_private_label_create_account(options)
450
+ email_direct_envelope(options) do |xml|
451
+ end
452
+ end
453
+
454
+ def parse_private_label_create_account(response)
455
+ ::EmailDirect::Response.new(response.body)
456
+ end
457
+
458
+ def build_private_label_get_child_accounts(options)
459
+ email_direct_envelope(options) do |xml|
460
+ end
461
+ end
462
+
463
+ def parse_private_label_get_child_accounts(response)
464
+ ::EmailDirect::Response.new(response.body)
465
+ end
466
+
467
+ def build_private_label_set_api_password(options)
468
+ email_direct_envelope(options) do |xml|
469
+ end
470
+ end
471
+
472
+ def parse_private_label_set_api_password(response)
473
+ ::EmailDirect::Response.new(response.body)
474
+ end
475
+
476
+ def build_publication_add(options)
477
+ email_direct_envelope(options) do |xml|
478
+ end
479
+ end
480
+
481
+ def parse_publication_add(response)
482
+ ::EmailDirect::Response.new(response.body)
483
+ end
484
+
485
+ def build_publication_delete(options)
486
+ email_direct_envelope(options) do |xml|
487
+ end
488
+ end
489
+
490
+ def parse_publication_delete(response)
491
+ ::EmailDirect::Response.new(response.body)
492
+ end
493
+
494
+ def build_publication_get_all(options)
495
+ email_direct_envelope(options) do |xml|
496
+ end
497
+ end
498
+
499
+ def parse_publication_get_all(response)
500
+ ::EmailDirect::Response.new(response.body)
501
+ end
502
+
503
+ def build_publication_get_subscribers(options)
504
+ email_direct_envelope(options) do |xml|
505
+ end
506
+ end
507
+
508
+ def parse_publication_get_subscribers(response)
509
+ ::EmailDirect::Response.new(response.body)
510
+ end
511
+
512
+ def build_publication_get_unsubscribes(options)
513
+ email_direct_envelope(options) do |xml|
514
+ end
515
+ end
516
+
517
+ def parse_publication_get_unsubscribes(response)
518
+ ::EmailDirect::Response.new(response.body)
519
+ end
520
+
521
+ def build_relay_send_create_category(options)
522
+ email_direct_envelope(options) do |xml|
523
+ end
524
+ end
525
+
526
+ def parse_relay_send_create_category(response)
527
+ ::EmailDirect::Response.new(response.body)
528
+ end
529
+
530
+ def build_relay_send_get_categories(options)
531
+ email_direct_envelope(options) do |xml|
532
+ end
533
+ end
534
+
535
+ def parse_relay_send_get_categories(response)
536
+ ::EmailDirect::Response.new(response.body)
537
+ end
538
+
539
+ def build_relay_send_get_category_stats(options)
540
+ email_direct_envelope(options) do |xml|
541
+ end
542
+ end
543
+
544
+ def parse_relay_send_get_category_stats(response)
545
+ ::EmailDirect::Response.new(response.body)
546
+ end
547
+
548
+ def build_relay_send_get_category_stats_for_tags(options)
549
+ email_direct_envelope(options) do |xml|
550
+ end
551
+ end
552
+
553
+ def parse_relay_send_get_category_stats_for_tags(response)
554
+ ::EmailDirect::Response.new(response.body)
555
+ end
556
+
557
+ def build_relay_send_get_details_for_receipt(options)
558
+ email_direct_envelope(options) do |xml|
559
+ end
560
+ end
561
+
562
+ def parse_relay_send_get_details_for_receipt(response)
563
+ ::EmailDirect::Response.new(response.body)
564
+ end
565
+
566
+ def build_relay_send_get_summary_for_receipts(options)
567
+ email_direct_envelope(options) do |xml|
568
+ end
569
+ end
570
+
571
+ def parse_relay_send_get_summary_for_receipts(response)
572
+ ::EmailDirect::Response.new(response.body)
573
+ end
574
+
575
+ def build_relay_send_send_email(options)
576
+ email_direct_envelope(options) do |xml|
577
+ end
578
+ end
579
+
580
+ def parse_relay_send_send_email(response)
581
+ ::EmailDirect::Response.new(response.body)
582
+ end
583
+
584
+ def build_relay_send_send_email_vars(options)
585
+ email_direct_envelope(options) do |xml|
586
+ end
587
+ end
588
+
589
+ def parse_relay_send_send_email_vars(response)
590
+ ::EmailDirect::Response.new(response.body)
591
+ end
592
+
593
+ def build_short_url_create(options)
594
+ email_direct_envelope(options) do |xml|
595
+ end
596
+ end
597
+
598
+ def parse_short_url_create(response)
599
+ ::EmailDirect::Response.new(response.body)
600
+ end
601
+
602
+ def build_short_url_get_stats(options)
603
+ email_direct_envelope(options) do |xml|
604
+ end
605
+ end
606
+
607
+ def parse_short_url_get_stats(response)
608
+ ::EmailDirect::Response.new(response.body)
609
+ end
610
+
611
+ def build_short_url_update_link(options)
612
+ email_direct_envelope(options) do |xml|
613
+ end
614
+ end
615
+
616
+ def parse_short_url_update_link(response)
617
+ ::EmailDirect::Response.new(response.body)
618
+ end
619
+
620
+ def build_source_add(options)
621
+ email_direct_envelope(options) do |xml|
622
+ end
623
+ end
624
+
625
+ def parse_source_add(response)
626
+ ::EmailDirect::Response.new(response.body)
627
+ end
628
+
629
+ def build_source_delete(options)
630
+ email_direct_envelope(options) do |xml|
631
+ end
632
+ end
633
+
634
+ def parse_source_delete(response)
635
+ ::EmailDirect::Response.new(response.body)
636
+ end
637
+
638
+ def build_source_get_all(options)
639
+ email_direct_envelope(options) do |xml|
640
+ end
641
+ end
642
+
643
+ def parse_source_get_all(response)
644
+ ::EmailDirect::Response.new(response.body)
645
+ end
646
+
647
+ def build_stats_day_of_week(options)
648
+ email_direct_envelope(options) do |xml|
649
+ end
650
+ end
651
+
652
+ def parse_stats_day_of_week(response)
653
+ ::EmailDirect::Response.new(response.body)
654
+ end
655
+
656
+ def build_stats_domain_over_time(options)
657
+ email_direct_envelope(options) do |xml|
658
+ end
659
+ end
660
+
661
+ def parse_stats_domain_over_time(response)
662
+ ::EmailDirect::Response.new(response.body)
663
+ end
664
+
665
+ def build_stats_hourly(options)
666
+ email_direct_envelope(options) do |xml|
667
+ end
668
+ end
669
+
670
+ def parse_stats_hourly(response)
671
+ ::EmailDirect::Response.new(response.body)
672
+ end
673
+
674
+ def build_stats_over_time(options)
675
+ email_direct_envelope(options) do |xml|
676
+ end
677
+ end
678
+
679
+ def parse_stats_over_time(response)
680
+ ::EmailDirect::Response.new(response.body)
681
+ end
682
+
683
+ def build_stats_source_over_time(options)
684
+ email_direct_envelope(options) do |xml|
685
+ end
686
+ end
687
+
688
+ def parse_stats_source_over_time(response)
689
+ ::EmailDirect::Response.new(response.body)
690
+ end
691
+
692
+ def build_stats_summary(options)
693
+ email_direct_envelope(options) do |xml|
694
+ end
695
+ end
696
+
697
+ def parse_stats_summary(response)
698
+ ::EmailDirect::Response.new(response.body)
699
+ end
700
+
701
+ def build_stats_top_domains(options)
702
+ email_direct_envelope(options) do |xml|
703
+ end
704
+ end
705
+
706
+ def parse_stats_top_domains(response)
707
+ ::EmailDirect::Response.new(response.body)
708
+ end
709
+
710
+ def build_stats_top_sources(options)
711
+ email_direct_envelope(options) do |xml|
712
+ end
713
+ end
714
+
715
+ def parse_stats_top_sources(response)
716
+ ::EmailDirect::Response.new(response.body)
717
+ end
718
+
719
+ def build_suppression_list_add(options)
720
+ email_direct_envelope(options) do |xml|
721
+ end
722
+ end
723
+
724
+ def parse_suppression_list_add(response)
725
+ ::EmailDirect::Response.new(response.body)
726
+ end
727
+
728
+ def build_suppression_list_add_domains(options)
729
+ email_direct_envelope(options) do |xml|
730
+ end
731
+ end
732
+
733
+ def parse_suppression_list_add_domains(response)
734
+ ::EmailDirect::Response.new(response.body)
735
+ end
736
+
737
+ def build_suppression_list_add_emails(options)
738
+ email_direct_envelope(options) do |xml|
739
+ end
740
+ end
741
+
742
+ def parse_suppression_list_add_emails(response)
743
+ ::EmailDirect::Response.new(response.body)
744
+ end
745
+
746
+ def build_suppression_list_delete(options)
747
+ email_direct_envelope(options) do |xml|
748
+ end
749
+ end
750
+
751
+ def parse_suppression_list_delete(response)
752
+ ::EmailDirect::Response.new(response.body)
753
+ end
754
+
755
+ def build_suppression_list_get_all(options)
756
+ email_direct_envelope(options) do |xml|
757
+ end
758
+ end
759
+
760
+ def parse_suppression_list_get_all(response)
761
+ ::EmailDirect::Response.new(response.body)
762
+ end
763
+
764
+ def build_suppression_list_get_members_simple(options)
765
+ email_direct_envelope(options) do |xml|
766
+ end
767
+ end
768
+
769
+ def parse_suppression_list_get_members_simple(response)
770
+ ::EmailDirect::Response.new(response.body)
771
+ end
772
+
773
+ def build_workflow_add_existing_emails(options)
774
+ email_direct_envelope(options) do |xml|
775
+ end
776
+ end
777
+
778
+ def parse_workflow_add_existing_emails(response)
779
+ ::EmailDirect::Response.new(response.body)
780
+ end
781
+
782
+ def build_workflow_add_to_workflows(options)
783
+ email_direct_envelope(options) do |xml|
784
+ end
785
+ end
786
+
787
+ def parse_workflow_add_to_workflows(response)
788
+ ::EmailDirect::Response.new(response.body)
789
+ end
790
+
791
+ def build_workflow_get_all(options)
792
+ email_direct_envelope(options) do |xml|
793
+ end
794
+ end
795
+
796
+ def parse_workflow_get_all(response)
797
+ ::EmailDirect::Response.new(response.body)
798
+ end
799
+
800
+ def build_workflow_get_send_nodes(options)
801
+ email_direct_envelope(options) do |xml|
802
+ end
803
+ end
804
+
805
+ def parse_workflow_get_send_nodes(response)
806
+ ::EmailDirect::Response.new(response.body)
807
+ end
808
+
809
+ def build_workflow_get_stats(options)
810
+ email_direct_envelope(options) do |xml|
811
+ end
812
+ end
813
+
814
+ def parse_workflow_get_stats(response)
815
+ ::EmailDirect::Response.new(response.body)
816
+ end
817
+
818
+ def build_workflow_get_stats_for_send_node(options)
819
+ email_direct_envelope(options) do |xml|
820
+ end
821
+ end
822
+
823
+ def parse_workflow_get_stats_for_send_node(response)
824
+ ::EmailDirect::Response.new(response.body)
825
+ end
826
+
827
+ def build_workflow_remove_emails(options)
828
+ email_direct_envelope(options) do |xml|
829
+ end
830
+ end
831
+
832
+ def parse_workflow_remove_emails(response)
833
+ ::EmailDirect::Response.new(response.body)
834
+ end
835
+
836
+ def build_workflow_start(options)
837
+ email_direct_envelope(options) do |xml|
838
+ end
839
+ end
840
+
841
+ def parse_workflow_start(response)
842
+ ::EmailDirect::Response.new(response.body)
843
+ end
844
+
845
+ def build_workflow_stop(options)
846
+ email_direct_envelope(options) do |xml|
847
+ end
848
+ end
849
+
850
+ def parse_workflow_stop(response)
851
+ ::EmailDirect::Response.new(response.body)
852
+ end
853
+
854
+ protected
855
+ def add_credentials!(xml)
856
+ xml.Creds(:xmlns=>"http://espapi.net/v1/components/credentials") do |cred|
857
+ cred.AccountName(@credentials["AccountName"])
858
+ cred.Password(@credentials["Password"])
859
+ cred.Enc(@credentials["Enc"])
860
+ end
861
+ end
862
+
863
+ # same as ServiceProxy email_direct_envelope method, except:
864
+ # 1) inject options hash directly
865
+ # 2) yields the raw xml (for incompatible activesupport style of array to xml)
866
+ # a hash with {"Lists" => [{:int => 1}, {:int => 2}]} will yields xml <Lists><List><int>1</int><List><int>2</int></Lists>
867
+ # 3) replace strange </ai> in generated xml
868
+ def email_direct_envelope(options, &block)
869
+ xsd = 'http://www.w3.org/2001/XMLSchema'
870
+ env = 'http://schemas.xmlsoap.org/soap/envelope/'
871
+ xsi = 'http://www.w3.org/2001/XMLSchema-instance'
872
+ data = options.clone
873
+ data.delete(:method)
874
+ data = data.to_xml(:skip_instruct => true, :skip_types => true).gsub("<hash>\n",'').gsub("</hash>\n",'')
875
+ xml = Builder::XmlMarkup.new
876
+ xml.env(:Envelope, 'xmlns:xsd' => xsd, 'xmlns:env' => env, 'xmlns:xsi' => xsi) do
877
+ xml.env(:Body) do
878
+ xml.__send__(options[:method].to_sym, 'xmlns' => self.target_namespace) do
879
+ add_credentials!(xml)
880
+ xml << data
881
+ end
882
+ end
883
+ end
884
+ raw = xml.target!
885
+ raw = raw.gsub('<ai/>','')
886
+ yield(raw) if block_given?
887
+ raw
888
+ end
889
+ end
890
+ end
891
+