eroi 0.1.4 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.1.4
1
+ 0.2.0
data/eroi.gemspec CHANGED
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{eroi}
8
- s.version = "0.1.4"
8
+ s.version = "0.2.0"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["CardPlayer"]
12
- s.date = %q{2009-12-07}
12
+ s.date = %q{2010-01-13}
13
13
  s.description = %q{API interface to eROI.}
14
14
  s.email = %q{techteam@cardplayer.com}
15
15
  s.extra_rdoc_files = [
data/lib/eroi/client.rb CHANGED
@@ -46,16 +46,34 @@ module EROI
46
46
  :clear_record => 1 ))
47
47
  end
48
48
 
49
- def send_list_edition_to_contact(list, edition, email)
50
- emails = ((email.is_a?(String)) ? [ email ] : email).join(',')
51
-
49
+ def define_list(list, records)
52
50
  xml = Builder::XmlMarkup.new
53
- xml.tag!('Send', emails, 'List' => list, 'Edition' => edition)
51
+ xml.tag!('DefineMailingList', 'list' => list) do |x|
52
+ records.each do |r|
53
+ x.tag!('Email', r.email)
54
+ end
55
+ end
54
56
 
55
57
  Request::Post.send(self, xml)
56
58
  end
57
59
 
58
- alias :send_list_edition_to_contacts :send_list_edition_to_contact
60
+ # Sends a list edition to specified broadcast.
61
+ #
62
+ # Who can consist of the following:
63
+ # * Broadcast All - sends to all members of the list, regardless of whether they have already received this edition
64
+ # * Broadcast Unsent - sends to all members of the list who have not yet received this edition
65
+ # * Broadcast ### - sends to ### random recipients who have not yet received this edition
66
+ # * A comma seperated list of emails.
67
+ def send_list_edition(list, edition, who)
68
+ xml = Builder::XmlMarkup.new
69
+ xml.tag!(
70
+ 'Send',
71
+ ((who.is_a?(String)) ? [ who ] : who).join(','),
72
+ 'List' => list,
73
+ 'Edition' => edition)
74
+
75
+ Request::Post.send(self, xml)
76
+ end
59
77
 
60
78
  private
61
79
 
@@ -108,12 +108,74 @@ class TestClient < Test::Unit::TestCase
108
108
  end
109
109
  end
110
110
 
111
- context "when sending an email to a contact" do
112
- should "respond with a success" do
113
- response = @client.send_list_edition_to_contact('TestList', 'test', 'longbob@longbob.com')
111
+ context "when sending an edition" do
112
+ setup do
113
+ @xml = mock('Builder::XmlMarkup')
114
+ end
114
115
 
115
- assert_equal true, response.success?
116
- assert_equal 1, response.number_of_records
116
+ context "when edition is meant for all contacts" do
117
+ should "respond with a success" do
118
+ @broadcast = 'Broadcast All'
119
+ @xml.expects('tag!').with('Send', @broadcast, 'List' => 'TestList', 'Edition' => 'test')
120
+ Builder::XmlMarkup.expects(:new).at_least_once.returns(@xml)
121
+
122
+ response = @client.send_list_edition('TestList', 'test', @broadcast)
123
+
124
+ assert_equal true, response.success?
125
+ assert_equal 1, response.number_of_records
126
+ end
127
+ end
128
+
129
+ context "when edition is meant for unsent contacts" do
130
+ should "respond with a success" do
131
+ @broadcast = 'Broadcast Unsent'
132
+ @xml.expects('tag!').with('Send', @broadcast, 'List' => 'TestList', 'Edition' => 'test')
133
+ Builder::XmlMarkup.expects(:new).at_least_once.returns(@xml)
134
+
135
+ response = @client.send_list_edition('TestList', 'test', @broadcast)
136
+
137
+ assert_equal true, response.success?
138
+ assert_equal 1, response.number_of_records
139
+ end
140
+ end
141
+
142
+ context "when edition is meant for random unsent contacts" do
143
+ should "respond with a success" do
144
+ @broadcast = 'Broadcast 200'
145
+ @xml.expects('tag!').with('Send', @broadcast, 'List' => 'TestList', 'Edition' => 'test')
146
+ Builder::XmlMarkup.expects(:new).at_least_once.returns(@xml)
147
+
148
+ response = @client.send_list_edition('TestList', 'test', @broadcast)
149
+
150
+ assert_equal true, response.success?
151
+ assert_equal 1, response.number_of_records
152
+ end
153
+ end
154
+
155
+ context "when edition is meant for a single contact" do
156
+ should "respond with a success" do
157
+ @broadcast = 'longbob@longbob.com'
158
+ @xml.expects('tag!').with('Send', @broadcast, 'List' => 'TestList', 'Edition' => 'test')
159
+ Builder::XmlMarkup.expects(:new).at_least_once.returns(@xml)
160
+
161
+ response = @client.send_list_edition('TestList', 'test', @broadcast)
162
+
163
+ assert_equal true, response.success?
164
+ assert_equal 1, response.number_of_records
165
+ end
166
+ end
167
+
168
+ context "when edition is meant for multiple contacts" do
169
+ should "respond with a success" do
170
+ @broadcast = [ 'longbob@longbob.com', 'shortbob@shortbob.com' ]
171
+ @xml.expects('tag!').with('Send', @broadcast.join(','), 'List' => 'TestList', 'Edition' => 'test')
172
+ Builder::XmlMarkup.expects(:new).at_least_once.returns(@xml)
173
+
174
+ response = @client.send_list_edition('TestList', 'test', @broadcast)
175
+
176
+ assert_equal true, response.success?
177
+ assert_equal 1, response.number_of_records
178
+ end
117
179
  end
118
180
  end
119
181
 
@@ -168,7 +168,7 @@ class TestClient < Test::Unit::TestCase
168
168
  :lastname => 'Longson',
169
169
  :mailing_lists => 'MainList')
170
170
 
171
- response = @client.send_list_edition_to_contact('MainList', 'Testing', 'longbob@longbob.com')
171
+ response = @client.send_list_edition('MainList', 'Testing', 'longbob@longbob.com')
172
172
 
173
173
  assert_equal true, response.success?
174
174
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: eroi
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.4
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - CardPlayer
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2009-12-07 00:00:00 -08:00
12
+ date: 2010-01-13 00:00:00 -08:00
13
13
  default_executable:
14
14
  dependencies: []
15
15