exact-target 0.0.4 → 0.0.5

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 CHANGED
@@ -1,3 +1,4 @@
1
+ v0.0.5. Fix corrupted gem
1
2
  v0.0.4. Fix gem to include CHANGELOG
2
3
  v0.0.3. Allow for passing ExactTarget::Subscriber into subscriber_add and subscriber_edit
3
4
  v0.0.2. Some minor cleanup
data/Gemfile ADDED
@@ -0,0 +1,8 @@
1
+ source :rubygems
2
+
3
+ gem "builder", ">= 3.0.0"
4
+ gem "nokogiri", ">= 1.4.4"
5
+
6
+ gem "rspec", '= 1.3.1', :require => false
7
+ gem 'simplecov', '>= 0.4.0', :require => false
8
+ gem "simplecov-rcov", ">= 0.2.0", :require => false
data/Gemfile.lock ADDED
@@ -0,0 +1,20 @@
1
+ GEM
2
+ remote: http://rubygems.org/
3
+ specs:
4
+ builder (3.0.0)
5
+ nokogiri (1.4.4)
6
+ rspec (1.3.1)
7
+ simplecov (0.4.2)
8
+ simplecov-html (~> 0.4.4)
9
+ simplecov-html (0.4.4)
10
+ simplecov-rcov (0.2.0)
11
+
12
+ PLATFORMS
13
+ ruby
14
+
15
+ DEPENDENCIES
16
+ builder (>= 3.0.0)
17
+ nokogiri (>= 1.4.4)
18
+ rspec (= 1.3.1)
19
+ simplecov (>= 0.4.0)
20
+ simplecov-rcov (>= 0.2.0)
data/Manifest CHANGED
@@ -1,7 +1,11 @@
1
1
  CHANGELOG
2
+ Gemfile
3
+ Gemfile.lock
2
4
  LICENSE
5
+ Manifest
3
6
  README.rdoc
4
7
  Rakefile
8
+ lib/exact-target.rb
5
9
  lib/exact_target.rb
6
10
  lib/exact_target/builder_ext.rb
7
11
  lib/exact_target/configuration.rb
@@ -12,11 +16,11 @@ lib/exact_target/response_class.erb
12
16
  lib/exact_target/response_classes.rb
13
17
  lib/exact_target/response_handler.rb
14
18
  lib/exact_target/string_ext.rb
19
+ lib/exacttarget.rb
15
20
  spec/exact_target/net_https_hack_spec.rb
16
21
  spec/exact_target/response_handler_spec.rb
17
22
  spec/exact_target/string_ext_spec.rb
18
23
  spec/exact_target_data.yml
19
24
  spec/exact_target_spec.rb
20
25
  spec/spec.opts
21
- spec/subscriber_list_spec.rb
22
- Manifest
26
+ spec/spec_helper.rb
data/README.rdoc CHANGED
@@ -20,7 +20,7 @@ http://github.com/ePublishing/exact_target
20
20
  == Prerequisites
21
21
 
22
22
  The ExactTarget gem depends on both Nokogiri and Builder. Both
23
- should be installed automatically when them gem is installed
23
+ should be installed automatically when the gem is installed
24
24
  (if not already installed).
25
25
 
26
26
  == Notes
data/Rakefile CHANGED
@@ -19,14 +19,6 @@ For more information consule http://www.exacttarget.com/.
19
19
  DONE
20
20
  end
21
21
 
22
- desc "Run all specs"
23
- Spec::Rake::SpecTask.new('spec') do |t|
24
- t.spec_opts = ['--options', %q("spec/spec.opts")]
25
- t.spec_files = FileList['spec/**/*_spec.rb']
26
- t.rcov = true
27
- t.rcov_opts = ['--exclude', 'spec']
28
- end
29
-
30
22
  desc 'generate API documentation to doc/rdocs/index.html'
31
23
  Rake::RDocTask.new do |rd|
32
24
  rd.rdoc_dir = 'doc/rdocs'
data/exact-target.gemspec CHANGED
@@ -1,30 +1,27 @@
1
1
  # -*- encoding: utf-8 -*-
2
2
 
3
3
  Gem::Specification.new do |s|
4
- s.name = %q{exact-target}
5
- s.version = "0.0.4"
4
+ s.name = "exact-target"
5
+ s.version = "0.0.5"
6
6
 
7
7
  s.required_rubygems_version = Gem::Requirement.new(">= 1.2") if s.respond_to? :required_rubygems_version=
8
8
  s.authors = ["David McCullars"]
9
- s.date = %q{2011-04-11}
10
- s.description = %q{This is a pure-ruby implementation of the ExactTarget api.
11
- For more information consule http://www.exacttarget.com/.
12
- }
13
- s.email = %q{dmccullars@ePublishing.com}
14
- s.extra_rdoc_files = ["CHANGELOG", "LICENSE", "README.rdoc"]
15
- s.files = ["CHANGELOG", "LICENSE", "README.rdoc", "Rakefile", "lib/exact_target.rb", "lib/exact_target/builder_ext.rb", "lib/exact_target/configuration.rb", "lib/exact_target/error.rb", "lib/exact_target/net_https_hack.rb", "lib/exact_target/request_builder.rb", "lib/exact_target/response_class.erb", "lib/exact_target/response_classes.rb", "lib/exact_target/response_handler.rb", "lib/exact_target/string_ext.rb", "spec/exact_target/net_https_hack_spec.rb", "spec/exact_target/response_handler_spec.rb", "spec/exact_target/string_ext_spec.rb", "spec/exact_target_data.yml", "spec/exact_target_spec.rb", "spec/spec.opts", "spec/subscriber_list_spec.rb", "Manifest", "exact-target.gemspec"]
16
- s.homepage = %q{http://github.com/ePublishing/exact_target}
9
+ s.date = "2011-10-25"
10
+ s.description = "This is a pure-ruby implementation of the ExactTarget api.\nFor more information consule http://www.exacttarget.com/.\n"
11
+ s.email = "dmccullars@ePublishing.com"
12
+ s.extra_rdoc_files = ["CHANGELOG", "LICENSE", "README.rdoc", "lib/exact-target.rb"]
13
+ s.files = ["CHANGELOG", "Gemfile", "Gemfile.lock", "LICENSE", "Manifest", "README.rdoc", "Rakefile", "lib/exact-target.rb", "lib/exact_target.rb", "lib/exact_target/builder_ext.rb", "lib/exact_target/configuration.rb", "lib/exact_target/error.rb", "lib/exact_target/net_https_hack.rb", "lib/exact_target/request_builder.rb", "lib/exact_target/response_class.erb", "lib/exact_target/response_classes.rb", "lib/exact_target/response_handler.rb", "lib/exact_target/string_ext.rb", "lib/exacttarget.rb", "spec/exact_target/net_https_hack_spec.rb", "spec/exact_target/response_handler_spec.rb", "spec/exact_target/string_ext_spec.rb", "spec/exact_target_data.yml", "spec/exact_target_spec.rb", "spec/spec.opts", "spec/spec_helper.rb", "exact-target.gemspec"]
14
+ s.homepage = "http://github.com/ePublishing/exact_target"
17
15
  s.rdoc_options = ["--line-numbers", "--inline-source", "--title", "Exact-target", "--main", "README.rdoc"]
18
16
  s.require_paths = ["lib"]
19
- s.rubyforge_project = %q{exact-target}
20
- s.rubygems_version = %q{1.3.6}
21
- s.summary = %q{This is a pure-ruby implementation of the ExactTarget api. For more information consule http://www.exacttarget.com/.}
17
+ s.rubyforge_project = "exact-target"
18
+ s.rubygems_version = "1.8.10"
19
+ s.summary = "This is a pure-ruby implementation of the ExactTarget api. For more information consule http://www.exacttarget.com/."
22
20
 
23
21
  if s.respond_to? :specification_version then
24
- current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
25
22
  s.specification_version = 3
26
23
 
27
- if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
24
+ if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
28
25
  else
29
26
  end
30
27
  else
@@ -0,0 +1 @@
1
+ require 'exact_target'
@@ -3,7 +3,7 @@ module ExactTarget
3
3
  class Configuration
4
4
 
5
5
  OPTIONS = [:base_url, :username, :password,
6
- :http_open_timeout, :http_read_timeout].freeze
6
+ :http_open_timeout, :http_read_timeout, :http_proxy].freeze
7
7
 
8
8
  # The (optional) base URL for accessing ExactTarget (can be http or https).
9
9
  # Defaults to 'https://api.dc1.exacttarget.com/integrate.aspx'
@@ -24,6 +24,9 @@ module ExactTarget
24
24
  # The (optional) HTTP read timeout in seconds (defaults to 5).
25
25
  attr_accessor :http_read_timeout
26
26
 
27
+ # The (optional) HTTP proxy url
28
+ attr_accessor :http_proxy
29
+
27
30
  def initialize
28
31
  @base_url = 'https://api.dc1.exacttarget.com/integrate.aspx'
29
32
  @http_open_timeout = 2
@@ -241,7 +241,6 @@ module ExactTarget
241
241
  def build(system_name, action, search_type=nil, search_value=nil, options=nil, &block)
242
242
  options = parse_options(search_type, search_value, options)
243
243
  xml = Builder::XmlMarkup.new
244
- xml.instruct! :xml, :version => "1.0", :encoding => nil
245
244
  xml = xml.exacttarget do |et|
246
245
  et.authorization do |a|
247
246
  a.username @config.username
@@ -251,7 +250,7 @@ module ExactTarget
251
250
  build_system(s, system_name, action, options, &block)
252
251
  end
253
252
  end
254
- xml.to_s
253
+ %Q[<?xml version="1.0"?>#{xml}]
255
254
  end
256
255
 
257
256
  def parse_options(search_type, search_value, options)
@@ -30,7 +30,7 @@ module ExactTarget
30
30
 
31
31
  def base.subscriber_class
32
32
  @subscriber_class ||= ResponseClasses.class_from_et_attributes(
33
- self, :Subscriber, accountinfo_retrieve_attrbs.map(&:name)
33
+ self, :Subscriber, accountinfo_retrieve_attrbs.map(&:name), :Status
34
34
  )
35
35
  end
36
36
 
@@ -44,7 +44,7 @@ module ExactTarget
44
44
  end
45
45
 
46
46
  def class_from_et_attributes(base, name, *attribute_names)
47
- attributes = attribute_names.flatten.map do |a|
47
+ attributes = attribute_names.flatten.uniq.map do |a|
48
48
  [a.to_s.underscore.gsub(' ', '_'), a.to_s.gsub(' ', '__')]
49
49
  end
50
50
  class_def = class_template.result(binding)
@@ -54,7 +54,7 @@ module ExactTarget
54
54
  def list_retrieve_sub(resp)
55
55
  resp.xpath('//subscriber').map do |s|
56
56
  return [] if s.text =~ /no subscribers found/i
57
- create_result(Subscriber, s)
57
+ create_result(ExactTarget::Subscriber, s)
58
58
  end
59
59
  end
60
60
 
@@ -84,7 +84,7 @@ module ExactTarget
84
84
  resp.xpath('//subscriber').map do |s|
85
85
  return [] if s.text =~ /no subscribers found/i
86
86
  sri = create_result(SubscriberInformation, s)
87
- sri.subscriber = create_result(Subscriber, s)
87
+ sri.subscriber = create_result(ExactTarget::Subscriber, s)
88
88
  sri
89
89
  end
90
90
  end
@@ -150,14 +150,14 @@ module ExactTarget
150
150
  case v
151
151
  when /^[+-]?\d+$/
152
152
  v.to_i
153
- when /^([+-]?)(?=\dâ\d)\d*(\.\d*)?([Ee]([+-]?\d+))?$/
153
+ when /^([+-]?)\d+(\.\d*)?([Ee]([+-]?\d+))?$/
154
154
  v.to_f
155
155
  when /^true$/i
156
156
  true
157
157
  when /^false$/i
158
158
  false
159
- when %r{^\d+/\d+/\d+ \d+:\d+:\d+ [AP]M$}i, %r{^\d+/\d+/\d+$}i
160
- DateTime.parse(v)
159
+ when %r<^\d\d?/\d\d?/\d{4}>
160
+ Date.strptime(v, "%m/%d/%Y")
161
161
  else
162
162
  v.strip
163
163
  end
data/lib/exact_target.rb CHANGED
@@ -72,7 +72,7 @@ module ExactTarget
72
72
  def send_to_exact_target(request)
73
73
  verify_configure
74
74
  uri = URI.parse "#{configuration.base_url}?qf=xml&xml=#{URI.escape request}"
75
- http = Net::HTTP.new(uri.host, uri.port)
75
+ http = net_http_or_proxy.new(uri.host, uri.port)
76
76
  http.use_ssl = configuration.secure?
77
77
  http.open_timeout = configuration.http_open_timeout
78
78
  http.read_timeout = configuration.http_read_timeout
@@ -93,6 +93,15 @@ module ExactTarget
93
93
 
94
94
  private
95
95
 
96
+ def net_http_or_proxy
97
+ if configuration.http_proxy
98
+ proxy_uri = URI.parse(configuration.http_proxy)
99
+ Net::HTTP.Proxy(proxy_uri.host, proxy_uri.port)
100
+ else
101
+ Net::HTTP
102
+ end
103
+ end
104
+
96
105
  def parse_response_xml(xml)
97
106
  verify_configure
98
107
  resp = Nokogiri.parse(xml)
@@ -0,0 +1 @@
1
+ require 'exact_target'
@@ -1,3 +1,5 @@
1
+ require 'spec_helper'
2
+
1
3
  describe 'ExactTarget::NetHttpsHack' do
2
4
 
3
5
  it "should ignore those annoying cert warnings" do
@@ -1,3 +1,5 @@
1
+ require 'spec_helper'
2
+
1
3
  describe ExactTarget::ResponseHandler do
2
4
 
3
5
  before(:all) do
@@ -12,4 +14,19 @@ describe ExactTarget::ResponseHandler do
12
14
  }.should raise_error(ExactTarget::Error, 'ExactTarget error #0: Unsupported id result: BOGUS<s>')
13
15
  end
14
16
 
17
+ context :cast_value do
18
+ ['3', 3,
19
+ '-5', -5,
20
+ '+3.79e-4', 0.000379,
21
+ 'true', true,
22
+ 'false', false,
23
+ '3/15/2002', Date.parse('2002-03-15'),
24
+ "\t a b \n", "a b",
25
+ ].each_slice(2) do |v, res|
26
+ it "should handle #{v}" do
27
+ @handler.send(:cast_value, v).should == res
28
+ end
29
+ end
30
+ end
31
+
15
32
  end
@@ -1,3 +1,5 @@
1
+ require 'spec_helper'
2
+
1
3
  describe 'ExactTarget::StringExt' do
2
4
 
3
5
  specify :underscore do
@@ -1,6 +1,4 @@
1
- require 'rubygems'
2
- require 'exact_target'
3
- require 'yaml'
1
+ require 'spec_helper'
4
2
 
5
3
  describe ExactTarget do
6
4
 
@@ -91,7 +89,7 @@ describe ExactTarget do
91
89
  @res.unsub_count.should == 1596
92
90
  @res.subscriber_count.should == 15287
93
91
  @res.bounce_count.should == 4145
94
- @res.modified.should be_a(DateTime)
92
+ @res.modified.should be_a(Date)
95
93
  @res.held_count.should == 120
96
94
  @res.list_type.should == 'Private'
97
95
  @res.active_total.should == 9426
@@ -117,6 +115,12 @@ describe ExactTarget do
117
115
  @res.should == 'Complete'
118
116
  end
119
117
 
118
+ specify "list_retrieve_sub with bogus status" do
119
+ expect do
120
+ ExactTarget.list_retrieve_sub(42, :bogus)
121
+ end.should raise_error(/Invalid status:/)
122
+ end
123
+
120
124
  test_et :list_retrieve_sub, 42, 'Active' do
121
125
  @res.size.should == 2
122
126
 
@@ -330,6 +334,23 @@ describe ExactTarget do
330
334
  expect { ExactTarget.bogus }.should raise_error
331
335
  end
332
336
 
337
+ context :net_http_or_proxy do
338
+ after { ExactTarget.configuration.http_proxy = nil }
339
+
340
+ specify :proxy do
341
+ ExactTarget.configuration.http_proxy = 'http://a.proxy.com:9001'
342
+ clazz = ExactTarget.send(:net_http_or_proxy)
343
+ # A proxy class should have the same methods
344
+ clazz.should_not == Net::HTTP
345
+ (Net::HTTP.methods - clazz.methods).should be_empty
346
+ (Net::HTTP.instance_methods - clazz.instance_methods).should be_empty
347
+ end
348
+
349
+ specify :standard do
350
+ ExactTarget.send(:net_http_or_proxy).should == Net::HTTP
351
+ end
352
+ end
353
+
333
354
  #################################################################
334
355
 
335
356
  private
@@ -0,0 +1,15 @@
1
+ require 'rubygems'
2
+
3
+ unless RUBY_VERSION.to_f < 1.9
4
+ require 'simplecov'
5
+ begin
6
+ require 'simplecov-rcov' # Formats in rcov format (so jenkins can consume)
7
+ SimpleCov.formatter = SimpleCov::Formatter::RcovFormatter
8
+ rescue Exception => e
9
+ # Ignore if it isn't installed
10
+ end
11
+ SimpleCov.start
12
+ end
13
+
14
+ require 'exact_target'
15
+ require 'yaml'
metadata CHANGED
@@ -1,12 +1,8 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: exact-target
3
3
  version: !ruby/object:Gem::Version
4
- prerelease: false
5
- segments:
6
- - 0
7
- - 0
8
- - 4
9
- version: 0.0.4
4
+ prerelease:
5
+ version: 0.0.5
10
6
  platform: ruby
11
7
  authors:
12
8
  - David McCullars
@@ -14,8 +10,7 @@ autorequire:
14
10
  bindir: bin
15
11
  cert_chain: []
16
12
 
17
- date: 2011-04-11 00:00:00 -04:00
18
- default_executable:
13
+ date: 2011-10-25 00:00:00 Z
19
14
  dependencies: []
20
15
 
21
16
  description: |
@@ -31,11 +26,16 @@ extra_rdoc_files:
31
26
  - CHANGELOG
32
27
  - LICENSE
33
28
  - README.rdoc
29
+ - lib/exact-target.rb
34
30
  files:
35
31
  - CHANGELOG
32
+ - Gemfile
33
+ - Gemfile.lock
36
34
  - LICENSE
35
+ - Manifest
37
36
  - README.rdoc
38
37
  - Rakefile
38
+ - lib/exact-target.rb
39
39
  - lib/exact_target.rb
40
40
  - lib/exact_target/builder_ext.rb
41
41
  - lib/exact_target/configuration.rb
@@ -46,16 +46,15 @@ files:
46
46
  - lib/exact_target/response_classes.rb
47
47
  - lib/exact_target/response_handler.rb
48
48
  - lib/exact_target/string_ext.rb
49
+ - lib/exacttarget.rb
49
50
  - spec/exact_target/net_https_hack_spec.rb
50
51
  - spec/exact_target/response_handler_spec.rb
51
52
  - spec/exact_target/string_ext_spec.rb
52
53
  - spec/exact_target_data.yml
53
54
  - spec/exact_target_spec.rb
54
55
  - spec/spec.opts
55
- - spec/subscriber_list_spec.rb
56
- - Manifest
56
+ - spec/spec_helper.rb
57
57
  - exact-target.gemspec
58
- has_rdoc: true
59
58
  homepage: http://github.com/ePublishing/exact_target
60
59
  licenses: []
61
60
 
@@ -70,24 +69,21 @@ rdoc_options:
70
69
  require_paths:
71
70
  - lib
72
71
  required_ruby_version: !ruby/object:Gem::Requirement
72
+ none: false
73
73
  requirements:
74
74
  - - ">="
75
75
  - !ruby/object:Gem::Version
76
- segments:
77
- - 0
78
76
  version: "0"
79
77
  required_rubygems_version: !ruby/object:Gem::Requirement
78
+ none: false
80
79
  requirements:
81
80
  - - ">="
82
81
  - !ruby/object:Gem::Version
83
- segments:
84
- - 1
85
- - 2
86
82
  version: "1.2"
87
83
  requirements: []
88
84
 
89
85
  rubyforge_project: exact-target
90
- rubygems_version: 1.3.6
86
+ rubygems_version: 1.8.10
91
87
  signing_key:
92
88
  specification_version: 3
93
89
  summary: This is a pure-ruby implementation of the ExactTarget api. For more information consule http://www.exacttarget.com/.
@@ -1,290 +0,0 @@
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