gnumarcelo-campaigning 0.11.1 → 0.12.0

Sign up to get free protection for your applications and to get access to all the features.
data/VERSION.yml CHANGED
@@ -1,4 +1,4 @@
1
1
  ---
2
2
  :major: 0
3
- :minor: 11
4
- :patch: 1
3
+ :minor: 12
4
+ :patch: 0
@@ -59,6 +59,32 @@ module Campaigning
59
59
  campaign_id = handle_response response.campaign_CreateResult
60
60
  Campaign.new campaign_id
61
61
  end
62
+
63
+ #Deletes an existing campaign.
64
+ #
65
+ #*Return*:
66
+ #
67
+ #*Success*: Upon a successful call, this method will return a Campaigning::Result object wich consists of a +code+ and +message+ fields
68
+ #containing a successful message.
69
+ #
70
+ #*Error*: An Exception containing the cause of the error will be raised.
71
+ def delete!
72
+ Campaign.delete!(@campaignID)
73
+ self.campaignID, self.subject, self.sentDate, self.totalRecipients = nil, nil, nil, nil
74
+ end
75
+
76
+ #Deletes an existing campaign.
77
+ #
78
+ #*Return*:
79
+ #
80
+ #*Success*: Upon a successful call, this method will return a Campaigning::Result object wich consists of a +code+ and +message+ fields
81
+ #containing a successful message.
82
+ #
83
+ #*Error*: An Exception containing the cause of the error will be raised.
84
+ def self.delete!(campaign_id)
85
+ response = @@soap.deleteCampaign(:apiKey => CAMPAIGN_MONITOR_API_KEY, :campaignID => list_id)
86
+ handle_response response.campaign_DeleteResult
87
+ end
62
88
 
63
89
  #Gets a list of all subscribers who bounced for a given campaign, and the type of bounce (H=Hard Bounce, S=Soft Bounce).
64
90
  #
@@ -1388,6 +1388,29 @@ class CampaignSendResponse
1388
1388
  end
1389
1389
  end
1390
1390
 
1391
+ # {http://api.createsend.com/api/}Campaign.Delete
1392
+ # apiKey - SOAP::SOAPString
1393
+ # campaignID - SOAP::SOAPString
1394
+ class CampaignDelete
1395
+ attr_accessor :apiKey
1396
+ attr_accessor :campaignID
1397
+
1398
+ def initialize(apiKey = nil, campaignID = nil)
1399
+ @apiKey = apiKey
1400
+ @campaignID = campaignID
1401
+ end
1402
+ end
1403
+
1404
+ # {http://api.createsend.com/api/}Campaign.DeleteResponse
1405
+ # campaign_DeleteResult - Campaigning::Result
1406
+ class CampaignDeleteResponse
1407
+ attr_accessor :campaign_DeleteResult
1408
+
1409
+ def initialize(campaign_DeleteResult = nil)
1410
+ @campaign_DeleteResult = campaign_DeleteResult
1411
+ end
1412
+ end
1413
+
1391
1414
  # {http://api.createsend.com/api/}anyType
1392
1415
  class AnyType < ::String
1393
1416
  def initialize(*arg)
@@ -311,6 +311,14 @@ class ApiSoap < ::SOAP::RPC::Driver
311
311
  { :request_style => :document, :request_use => :literal,
312
312
  :response_style => :document, :response_use => :literal,
313
313
  :faults => {} }
314
+ ],
315
+ [ "http://api.createsend.com/api/Campaign.Delete",
316
+ "deleteCampaign",
317
+ [ ["in", "parameters", ["::SOAP::SOAPElement", "http://api.createsend.com/api/", "Campaign.Delete"]],
318
+ ["out", "parameters", ["::SOAP::SOAPElement", "http://api.createsend.com/api/", "Campaign.DeleteResponse"]] ],
319
+ { :request_style => :document, :request_use => :literal,
320
+ :response_style => :document, :response_use => :literal,
321
+ :faults => {} }
314
322
  ]
315
323
  ]
316
324
 
@@ -1266,6 +1266,23 @@ module DefaultMappingRegistry
1266
1266
  ]
1267
1267
  )
1268
1268
 
1269
+ LiteralRegistry.register(
1270
+ :class => Campaigning::CampaignDelete,
1271
+ :schema_name => XSD::QName.new(NsApi, "Campaign.Delete"),
1272
+ :schema_element => [
1273
+ ["apiKey", ["SOAP::SOAPString", XSD::QName.new(NsApi, "ApiKey")], [0, 1]],
1274
+ ["campaignID", ["SOAP::SOAPString", XSD::QName.new(NsApi, "CampaignID")], [0, 1]]
1275
+ ]
1276
+ )
1277
+
1278
+ LiteralRegistry.register(
1279
+ :class => Campaigning::CampaignDeleteResponse,
1280
+ :schema_name => XSD::QName.new(NsApi, "Campaign.DeleteResponse"),
1281
+ :schema_element => [
1282
+ ["campaign_DeleteResult", ["Campaigning::Result", XSD::QName.new(NsApi, "Campaign.DeleteResult")], [0, 1]]
1283
+ ]
1284
+ )
1285
+
1269
1286
  LiteralRegistry.register(
1270
1287
  :class => Campaigning::Result,
1271
1288
  :schema_name => XSD::QName.new(NsApi, "Result"),
@@ -98,7 +98,7 @@ module Campaigning
98
98
  #containing a successful message.
99
99
  #
100
100
  #*Error*: An Exception containing the cause of the error will be raised.
101
- def unsubscribe(list_id)
101
+ def unsubscribe!(list_id)
102
102
  Subscriber.unsubscribe!(@emailAddress, list_id)
103
103
  end
104
104
 
@@ -0,0 +1,102 @@
1
+ require 'test_helper'
2
+
3
+ # Replace this API key with your own (http://www.campaignmonitor.com/api/)
4
+ CAMPAIGN_MONITOR_API_KEY = '__PUT_YOUR_API_KEY_HERE__'
5
+
6
+ class CampaignTest < Test::Unit::TestCase
7
+
8
+
9
+ def setup
10
+ #Campaigning.set_endpoint_url "http://127.0.0.1:8088/mockapiSoap"
11
+ Campaigning.set_debug_mode(:on)
12
+ end
13
+
14
+ def test_campaign_create
15
+ client = Campaigning::Client.find_by_name("Client One Company")
16
+ response = Campaigning::Campaign.create!(
17
+ :clientID => client.clientID,
18
+ :campaignName => "Campaign by Campaigning TO DELETE - CODEE",
19
+ :campaignSubject => "Campaign by myself - OK - CODEE",
20
+ :fromName => "Mr. Gordon23",
21
+ :fromEmail => "gordon23@test.com",
22
+ :replyTo => "no-reply@test.com",
23
+ :htmlUrl => "http://www.google.com.br",
24
+ :textUrl => "http://www.google.com.br",
25
+ :subscriberListIDs => ["ac52b645c048888a44c87b5f1ecf6b7d"],
26
+ :listSegments => client.segments
27
+ )
28
+ puts response.inspect
29
+ end
30
+
31
+
32
+ # def test_campaign_delete!
33
+ # client = Campaigning::Client.find_by_name("Client One Company")
34
+ # response = Campaigning::Campaign.delete!(response)
35
+ # puts response.inspect
36
+ # end
37
+
38
+ # def test_campaign_bounces
39
+ # client = Campaigning::Client.find_by_name("Client One Company")
40
+ # puts client.campaigns[1].bounces.inspect
41
+ # end
42
+ #
43
+ # def test_campaign_lists
44
+ # client = Campaigning::Client.find_by_name("Client One Company")
45
+ # client.campaigns[0].lists
46
+ # end
47
+ #
48
+ # def test_campaign_opens
49
+ # client = Campaigning::Client.find_by_name("Client One Company")
50
+ # puts client.campaigns[0].opens
51
+ # end
52
+ #
53
+ # def test_campaign_find_campaigns_by_subject
54
+ # client = Campaigning::Client.find_by_name("Client One Company")
55
+ # campaigns = client.find_campaigns_by_subject("Campaign to BOUNCE")
56
+ # assert campaign.length > 0
57
+ # end
58
+ #
59
+ #
60
+ # def test_campaign_summary
61
+ # client = Campaigning::Client.find_by_name("Client One Company")
62
+ # # client.campaigns[2].subscriber_clicks.each do |subscriber|
63
+ # # puts "Subscriber: #{subscriber.emailAddress}"
64
+ # # subscriber.clickedLinks.each { |clicked| puts "Link: #{clicked.link} - Number of clicks: #{clicked.clicks}"}
65
+ # # end
66
+ # assert client.campaigns[2].subscriber_clicks != nil
67
+ # assert client.campaigns[2].subscriber_clicks != []
68
+ #
69
+ # end
70
+ #
71
+ #
72
+ # def test_campaign_summary
73
+ # client = Campaigning::Client.find_by_name("Client One Company")
74
+ # puts client.campaigns[1].summary
75
+ # end
76
+ #
77
+ # def test_campaign_unsubscribes
78
+ # client = Campaigning::Client.find_by_name("Client One Company")
79
+ # puts client.campaigns[0].unsubscribes
80
+ # end
81
+ #
82
+ # def test_campaign_send
83
+ # client = Campaigning::Client.find_by_name("Client One Company")
84
+ # response = Campaigning::Campaign.create!(
85
+ # :clientID => client.clientID,
86
+ # :campaignName => "Campaign by myself RUBY NEW CREATED",
87
+ # :campaignSubject => "Campaign by myself - OK",
88
+ # :fromName => "Mr. Gordon2",
89
+ # :fromEmail => "gordon2@test.com",
90
+ # :replyTo => "no-reply@test.com",
91
+ # :htmlUrl => "http://www.campaignmonitor.com/api/method/campaign-create/",
92
+ # :textUrl => "http://www.google.com",
93
+ # :subscriberListIDs => ["ac52b645c048888a44c87b5f1ecf6b7d"],
94
+ # :listSegments => client.segments
95
+ # )
96
+ #
97
+ # puts client.campaigns[0].send!(
98
+ # :confirmationEmail => "userhdhd@test.com",
99
+ # :sendDate => "2009-04-30 11:55:01" # Date format YYYY-MM-DD HH:MM:SS.
100
+ # )
101
+ # end
102
+ end
@@ -8,358 +8,33 @@ class CampaigningTest < Test::Unit::TestCase
8
8
 
9
9
  def setup
10
10
  #Campaigning.set_endpoint_url "http://127.0.0.1:8088/mockapiSoap"
11
- Campaigning.set_debug_mode(:on)
12
11
  end
13
12
 
14
- # def test_campaigning_system_date
15
- # date = Campaigning.system_date
16
- # assert !date.nil?
17
- # end
18
- #
19
- # def test_user_get_timezones
20
- # timezones = Campaigning.timezones
21
- # assert !timezones.nil?
22
- # end
23
- #
24
- # def test_user_countries
25
- # countries = Campaigning.countries
26
- # assert !countries.nil?
27
- # end
28
- #
29
- # def test_client_get_all_clients
30
- # clients = Campaigning::Client.get_all_clients
31
- # assert clients.length > 0
32
- # #clients.each{ |c| puts c.clientID + " - " + c.name }
33
- # end
34
- #
35
- # def test_client_lists
36
- # client = Campaigning::Client.find_by_name("Client One Company")
37
- # assert client.lists.length > 0
38
- # end
39
-
40
-
41
- # def test_client_create!
42
- # client_created = Campaigning::Client.create!(
43
- # :companyName => "My test clients22",
44
- # :contactName => "Oswald Green15s25",
45
- # :emailAddress => "og1524s@example.com",
46
- # :country => "Ireland",
47
- # :timezone => Campaigning.timezones[1]
48
- # )
49
- # assert !client_created.clientID.nil?
50
- # end
51
- #
52
- # def test_client_delete
53
- # response = Campaigning::Client.delete!(client_created.clientID)
54
- # assert response.code == 0
55
- # end
56
- #
57
- # def test_client_delete_itself
58
- # client = Campaigning::Client.find_by_name("Orange Company 7")
59
- # client.delete!
60
- # end
61
-
62
- # def test_client_segments
63
- # client = Campaigning::Client.find_by_name("Client One Company")
64
- # assert client.segments.length > 0
65
- # end
66
- #
67
- #
68
- # def test_find_client_by_name
69
- # client = Campaigning::Client.find_by_name("Client One Company")
70
- # assert !client.nil? && client.name == "Client One Company"
71
- # end
72
- #
73
- #
74
- # def test_get_client_campaigns
75
- # client = Campaigning::Client.find_by_name("Client One Company")
76
- # puts client.campaigns.inspect
77
- # end
78
- #
79
- # def test_get_client_details
80
- # client = Campaigning::Client.find_by_name("Client One Company")
81
- # # client_details = client.details
82
- # # basic_details = client_details.basicDetails
83
- # # access_and_billing_details = client_details.accessAndBilling
84
- # # puts "Basic details:"
85
- # # puts "Client ID: #{basic_details.clientID} - \n
86
- # # Company: #{basic_details.companyName} - \n
87
- # # Contact: #{basic_details.contactName} - \n
88
- # # Country: #{basic_details.country} - \n
89
- # # Timezone: #{basic_details.timezone}"
90
- # #
91
- # # puts "Access and Billing Details:"
92
- # # puts "Username: #{access_and_billing_details.username} - \n
93
- # # Password: #{access_and_billing_details.password} - \n
94
- # # Billing Type: #{access_and_billing_details.billingType} - \n
95
- # # Currency: #{access_and_billing_details.currency} - \n
96
- # # Delivery Fee: #{access_and_billing_details.deliveryFee} - \n
97
- # # Cost per Recipient: #{access_and_billing_details.costPerRecipient} - \n
98
- # # Design and Span test Fee: #{access_and_billing_details.designAndSpamTestFee} - \n
99
- # # Access Level: #{access_and_billing_details.accessLevel}"
100
- #
101
- # assert !client.details.nil?
102
- #
103
- # end
104
- #
105
- # def test_get_client_suppression_list
106
- # client = Campaigning::Client.find_by_name("Client One Company")
107
- # puts client.suppression_list.inspect
108
- # end
109
- #
110
- # # def test_client_update_access_and_billing!
111
- # # client = Campaigning::Client.find_by_name("Client One Company")
112
- # # response = client.update_access_and_billing!(
113
- # # :accessLevel => 5 ,
114
- # # :username => "client_one",
115
- # # :password => "1234560",
116
- # # :billingType => "UserPaysOnClientsBehalf",
117
- # # :currency => "USD",
118
- # # :deliveryFee => 6.5,
119
- # # :costPerRecipient => 1.5 ,
120
- # # :designAndSpamTestFee => 5
121
- # # )
122
- # # assert response.code == 0
123
- # # end
124
- # #
125
- # # def test_client_update_basics!
126
- # # client = Campaigning::Client.find_by_name("Client Two")
127
- # # response = client.update_basics!(
128
- # # :companyName => "My new Company",
129
- # # :contactName => "Mr. Gordon Newman",
130
- # # :emailAddress => "gordon-newman@test.com",
131
- # # :country => "Ireland",
132
- # # :timezone => Campaigning.timezones[1]
133
- # # )
134
- # # assert response.code == 0
135
- # # end
136
- #
137
- # def test_client_find_list_by_name
138
- # client = Campaigning::Client.find_by_name("Client One Company")
139
- # list = client.find_list_by_name "My Friends"
140
- # assert list.nil? == false
141
- # end
142
-
143
-
144
- # def test_campaign_create
145
- # client = Campaigning::Client.find_by_name("Client One Company")
146
- # response = Campaigning::Campaign.create!(
147
- # :clientID => client.clientID,
148
- # :campaignName => "Campaign by myself RUBY TO DELETE - CODEEEEE",
149
- # :campaignSubject => "Campaign by myself - OK - CODEEEEE",
150
- # :fromName => "Mr. Gordon2",
151
- # :fromEmail => "gordon2@test.com",
152
- # :replyTo => "no-reply@test.com",
153
- # :htmlUrl => "http://www.campaignmonitor.com/api/method/campaign-create/",
154
- # :textUrl => "http://www.google.com.br",
155
- # :subscriberListIDs => ["ac52b645c048888a44c87b5f1ecf6b7d"],
156
- # :listSegments => client.segments
157
- # )
158
- # puts response.inspect
159
- # end
160
- #
161
- #
162
- # def test_campaign_bounces
163
- # client = Campaigning::Client.find_by_name("Client One Company")
164
- # puts client.campaigns[1].bounces.inspect
165
- # end
166
- #
167
- # def test_campaign_lists
168
- # client = Campaigning::Client.find_by_name("Client One Company")
169
- # client.campaigns[0].lists
170
- # end
171
- #
172
- # def test_campaign_opens
173
- # client = Campaigning::Client.find_by_name("Client One Company")
174
- # puts client.campaigns[0].opens
175
- # end
176
- #
177
- # def test_campaign_find_campaigns_by_subject
178
- # client = Campaigning::Client.find_by_name("Client One Company")
179
- # campaigns = client.find_campaigns_by_subject("Campaign to BOUNCE")
180
- # assert campaign.length > 0
181
- # end
182
- #
183
- #
184
- # def test_campaign_summary
185
- # client = Campaigning::Client.find_by_name("Client One Company")
186
- # # client.campaigns[2].subscriber_clicks.each do |subscriber|
187
- # # puts "Subscriber: #{subscriber.emailAddress}"
188
- # # subscriber.clickedLinks.each { |clicked| puts "Link: #{clicked.link} - Number of clicks: #{clicked.clicks}"}
189
- # # end
190
- # assert client.campaigns[2].subscriber_clicks != nil
191
- # assert client.campaigns[2].subscriber_clicks != []
192
- #
193
- # end
194
- #
195
- #
196
- # def test_campaign_summary
197
- # client = Campaigning::Client.find_by_name("Client One Company")
198
- # puts client.campaigns[1].summary
199
- # end
200
- #
201
- # def test_campaign_unsubscribes
202
- # client = Campaigning::Client.find_by_name("Client One Company")
203
- # puts client.campaigns[0].unsubscribes
204
- # end
205
- #
206
- # def test_campaign_send
207
- # client = Campaigning::Client.find_by_name("Client One Company")
208
- # response = Campaigning::Campaign.create!(
209
- # :clientID => client.clientID,
210
- # :campaignName => "Campaign by myself RUBY NEW CREATED",
211
- # :campaignSubject => "Campaign by myself - OK",
212
- # :fromName => "Mr. Gordon2",
213
- # :fromEmail => "gordon2@test.com",
214
- # :replyTo => "no-reply@test.com",
215
- # :htmlUrl => "http://www.campaignmonitor.com/api/method/campaign-create/",
216
- # :textUrl => "http://www.google.com",
217
- # :subscriberListIDs => ["ac52b645c048888a44c87b5f1ecf6b7d"],
218
- # :listSegments => client.segments
219
- # )
220
- #
221
- # puts client.campaigns[0].send!(
222
- # :confirmationEmail => "userhdhd@test.com",
223
- # :sendDate => "2009-04-30 11:55:01" # Date format YYYY-MM-DD HH:MM:SS.
224
- # )
225
- # end
226
- #
227
- # def test_subscriber_add
228
- # subscriber = Campaigning::Subscriber.new("robertf@test.com", "Robert Franklin")
229
- # response = subscriber.add!("ac52b645c048888a44c87b5f1ecf6b7d")
230
- # assert response.code == 0
231
- # end
232
- #
233
- # def test_subscriber_add_with_custom_fields
234
- # subscriber = Campaigning::Subscriber.new("user_custon2@test.com", "Mr. Custon")
235
- # response = subscriber.add!("ac52b645c048888a44c87b5f1ecf6b7d", :CityName => "London", :SponsorName => "Some Sponsor from London")
236
- # assert response.code == 0
237
- # end
238
-
239
- def test_subscriber_add_and_resubscribe
240
- subscriber = Campaigning::Subscriber.new("norag@test.com", "Nora Green")
241
- response = subscriber.add_and_resubscribe!("ac52b645c048888a44c87b5f1ecf6b7d")
242
- assert response.code == 0
13
+ def test_campaigning_system_date
14
+ date = Campaigning.system_date
15
+ assert !date.nil?
243
16
  end
244
17
 
18
+ def test_user_get_timezones
19
+ timezones = Campaigning.timezones
20
+ assert !timezones.nil?
21
+ end
245
22
 
246
- def test_subscriber_add_and_resubscribe_with_custom_fields
247
- subscriber = Campaigning::Subscriber.new("user_custon@test.com", "Mr. Custon")
248
- response = subscriber.add_and_resubscribe!("ac52b645c048888a44c87b5f1ecf6b7d", :CityName => "Dublin", :SponsorName => "Some Sponsor")
249
- assert response.code == 0
23
+ def test_user_countries
24
+ countries = Campaigning.countries
25
+ assert !countries.nil?
26
+ end
27
+
28
+ def test_client_get_all_clients
29
+ clients = Campaigning::Client.get_all_clients
30
+ assert clients.length > 0
31
+ #clients.each{ |c| puts c.clientID + " - " + c.name }
250
32
  end
251
-
252
33
 
253
- #
254
- # def test_subscriber_unsubscribe
255
- # subscriber = Campaigning::Subscriber.new("user_to_test@test.com") # TODO: Change to get the Subscriber, not to CREATE a new one
256
- # response = subscriber.unsubscribe!("ac52b645c048888a44c87b5f1ecf6b7d")
257
- # puts response.inspect
258
- # assert response.code == 0
259
- # end
260
- #
261
- #
262
- # def test_subscriber_is_subscribed
263
- # subscriber = Campaigning::Subscriber.new("user_to_test@test.com") # TODO: Change to get the Subscriber, not to CREATE a new one
264
- # response = subscriber.is_subscribed?("ac52b645c048888a44c87b5f1ecf6b7d")
265
- # puts response.inspect
266
- # assert response == false
267
- # end
268
- #
269
- #
270
- # def test_list_find_single_subscriber
271
- # client = Campaigning::Client.find_by_name("Client One Company")
272
- # list = client.find_list_by_name "My Friends"
273
- # subscriber = list.find_single_subscriber("user_custon2@test.com")
274
- # puts subscriber.inspect
275
- # assert subscriber.name != nil
276
- # end
277
- #
278
- # def test_list_find_unsubscribed
279
- # client = Campaigning::Client.find_by_name("Client One Company")
280
- # list = client.find_list_by_name "My Friends"
281
- # subscriber_list = list.find_unsubscribed(DateTime.new(y=2009,m=4,d=01, h=01,min=00,s=00))
282
- # puts subscriber_list.inspect
283
- # assert subscriber_list.length > 0
284
- # end
285
- #
286
- # def test_list_find_active_subscribers
287
- # client = Campaigning::Client.find_by_name("Client One Company")
288
- # list = client.find_list_by_name "My Friends"
289
- # subscriber_list = list.find_active_subscribers(DateTime.new(y=2009,m=5,d=01, h=01,min=00,s=00))
290
- # assert subscriber_list.length > 0
291
- # end
292
- #
293
- # def test_list_get_all_active_subscribers
294
- # client = Campaigning::Client.find_by_name("Client One Company")
295
- # list = client.find_list_by_name "My Friends"
296
- # subscriber_list = list.get_all_active_subscribers
297
- # puts subscriber_list.inspect
298
- # assert subscriber_list.length > 0
299
- # end
300
- #
301
- #
302
- #
303
- # def test_list_create
304
- # client = Campaigning::Client.find_by_name("Client One Company")
305
- # list = Campaigning::List.create!(
306
- # :clientID => client.clientID,
307
- # :title => "New list to test",
308
- # :unsubscribePage => "",
309
- # :confirmOptIn => false,
310
- # :confirmationSuccessPage => ""
311
- # )
312
- # assert list.listID != nil
313
- # end
314
- #
315
- # def test_list_create_custom_field
316
- # client = Campaigning::Client.find_by_name("Client One Company")
317
- # list = client.find_list_by_name "My Friends"
318
- # result = list.create_custom_field!(
319
- # :fieldName => "Country" ,
320
- # :dataType => "MultiSelectOne",
321
- # :options => %w[Brazil Ireland England]
322
- # )
323
- # assert result.code == 0
324
- # end
325
- #
326
- # def test_list_delete
327
- # result = Campaigning::List.delete!("916797045feddc92df10a4722f819771")
328
- # puts result.inspect
329
- # end
330
- #
331
- # def test_list_delete_custom_field
332
- # client = Campaigning::Client.find_by_name("Client One Company")
333
- # list = client.find_list_by_name "My Friends"
334
- # result = list.delete_custom_field!("Country")
335
- # assert result.code == 0
336
- # end
337
- #
338
- # def test_list_custom_fields
339
- # client = Campaigning::Client.find_by_name("Client One Company")
340
- # list = client.find_list_by_name "My Friends"
341
- # result = list.custom_fields
342
- # puts result.inspect
343
- # end
344
- #
345
- # def test_list_details
346
- # client = Campaigning::Client.find_by_name("Client One Company")
347
- # list = client.find_list_by_name "My Friends"
348
- # result = list.details
349
- # puts result.inspect
350
- # end
351
- #
352
- # def test_list_update
353
- # client = Campaigning::Client.find_by_name("Client One Company")
354
- # list = client.find_list_by_name "My Friends"
355
- # result = list.update!(
356
- # :title => "NEW TITLE : My new list created by ruby list.create",
357
- # :unsubscribePage => "",
358
- # :confirmOptIn => false,
359
- # :confirmationSuccessPage => ""
360
- # )
361
- # assert result.code == 0
362
- # end
34
+ def test_client_lists
35
+ client = Campaigning::Client.find_by_name("Client One Company")
36
+ assert client.lists.length > 0
37
+ end
363
38
 
364
39
 
365
40
  end
@@ -0,0 +1,116 @@
1
+ require 'test_helper'
2
+
3
+ # Replace this API key with your own (http://www.campaignmonitor.com/api/)
4
+ CAMPAIGN_MONITOR_API_KEY = '__PUT_YOUR_API_KEY_HERE__'
5
+
6
+ class ClientTest < Test::Unit::TestCase
7
+
8
+
9
+ def setup
10
+ #Campaigning.set_endpoint_url "http://127.0.0.1:8088/mockapiSoap"
11
+ Campaigning.set_debug_mode(:on)
12
+ end
13
+
14
+ def test_client_create!
15
+ client_created = Campaigning::Client.create!(
16
+ :companyName => "My test clients22",
17
+ :contactName => "Oswald Green15s25",
18
+ :emailAddress => "og1524s@example.com",
19
+ :country => "Ireland",
20
+ :timezone => Campaigning.timezones[1]
21
+ )
22
+ assert !client_created.clientID.nil?
23
+ end
24
+
25
+ def test_client_delete
26
+ response = Campaigning::Client.delete!(client_created.clientID)
27
+ assert response.code == 0
28
+ end
29
+
30
+ def test_client_delete_itself
31
+ client = Campaigning::Client.find_by_name("Orange Company 7")
32
+ client.delete!
33
+ end
34
+
35
+ def test_client_segments
36
+ client = Campaigning::Client.find_by_name("Client One Company")
37
+ assert client.segments.length > 0
38
+ end
39
+
40
+
41
+ def test_find_client_by_name
42
+ client = Campaigning::Client.find_by_name("Client One Company")
43
+ assert !client.nil? && client.name == "Client One Company"
44
+ end
45
+
46
+
47
+ def test_get_client_campaigns
48
+ client = Campaigning::Client.find_by_name("Client One Company")
49
+ puts client.campaigns.inspect
50
+ end
51
+
52
+ def test_get_client_details
53
+ client = Campaigning::Client.find_by_name("Client One Company")
54
+ # client_details = client.details
55
+ # basic_details = client_details.basicDetails
56
+ # access_and_billing_details = client_details.accessAndBilling
57
+ # puts "Basic details:"
58
+ # puts "Client ID: #{basic_details.clientID} - \n
59
+ # Company: #{basic_details.companyName} - \n
60
+ # Contact: #{basic_details.contactName} - \n
61
+ # Country: #{basic_details.country} - \n
62
+ # Timezone: #{basic_details.timezone}"
63
+ #
64
+ # puts "Access and Billing Details:"
65
+ # puts "Username: #{access_and_billing_details.username} - \n
66
+ # Password: #{access_and_billing_details.password} - \n
67
+ # Billing Type: #{access_and_billing_details.billingType} - \n
68
+ # Currency: #{access_and_billing_details.currency} - \n
69
+ # Delivery Fee: #{access_and_billing_details.deliveryFee} - \n
70
+ # Cost per Recipient: #{access_and_billing_details.costPerRecipient} - \n
71
+ # Design and Span test Fee: #{access_and_billing_details.designAndSpamTestFee} - \n
72
+ # Access Level: #{access_and_billing_details.accessLevel}"
73
+
74
+ assert !client.details.nil?
75
+
76
+ end
77
+
78
+ def test_get_client_suppression_list
79
+ client = Campaigning::Client.find_by_name("Client One Company")
80
+ puts client.suppression_list.inspect
81
+ end
82
+
83
+ def test_client_update_access_and_billing!
84
+ client = Campaigning::Client.find_by_name("Client One Company")
85
+ response = client.update_access_and_billing!(
86
+ :accessLevel => 5 ,
87
+ :username => "client_one",
88
+ :password => "1234560",
89
+ :billingType => "UserPaysOnClientsBehalf",
90
+ :currency => "USD",
91
+ :deliveryFee => 6.5,
92
+ :costPerRecipient => 1.5 ,
93
+ :designAndSpamTestFee => 5
94
+ )
95
+ assert response.code == 0
96
+ end
97
+
98
+ def test_client_update_basics!
99
+ client = Campaigning::Client.find_by_name("Client Two")
100
+ response = client.update_basics!(
101
+ :companyName => "My new Company",
102
+ :contactName => "Mr. Gordon Newman",
103
+ :emailAddress => "gordon-newman@test.com",
104
+ :country => "Ireland",
105
+ :timezone => Campaigning.timezones[1]
106
+ )
107
+ assert response.code == 0
108
+ end
109
+
110
+ def test_client_find_list_by_name
111
+ client = Campaigning::Client.find_by_name("Client One Company")
112
+ list = client.find_list_by_name "My Friends"
113
+ assert list.nil? == false
114
+ end
115
+
116
+ end
data/test/list_test.rb ADDED
@@ -0,0 +1,106 @@
1
+ require 'test_helper'
2
+
3
+ # Replace this API key with your own (http://www.campaignmonitor.com/api/)
4
+ CAMPAIGN_MONITOR_API_KEY = '__PUT_YOUR_API_KEY_HERE__'
5
+
6
+ class ListTest < Test::Unit::TestCase
7
+
8
+
9
+ def setup
10
+ #Campaigning.set_endpoint_url "http://127.0.0.1:8088/mockapiSoap"
11
+ Campaigning.set_debug_mode(:on)
12
+ end
13
+
14
+
15
+ def test_list_find_single_subscriber
16
+ client = Campaigning::Client.find_by_name("Client One Company")
17
+ list = client.find_list_by_name "My Friends"
18
+ subscriber = list.find_single_subscriber("user_custon2@test.com")
19
+ puts subscriber.inspect
20
+ assert subscriber.name != nil
21
+ end
22
+
23
+ def test_list_find_unsubscribed
24
+ client = Campaigning::Client.find_by_name("Client One Company")
25
+ list = client.find_list_by_name "My Friends"
26
+ subscriber_list = list.find_unsubscribed(DateTime.new(y=2009,m=4,d=01, h=01,min=00,s=00))
27
+ puts subscriber_list.inspect
28
+ assert subscriber_list.length > 0
29
+ end
30
+
31
+ def test_list_find_active_subscribers
32
+ client = Campaigning::Client.find_by_name("Client One Company")
33
+ list = client.find_list_by_name "My Friends"
34
+ subscriber_list = list.find_active_subscribers(DateTime.new(y=2009,m=5,d=01, h=01,min=00,s=00))
35
+ assert subscriber_list.length > 0
36
+ end
37
+
38
+ def test_list_get_all_active_subscribers
39
+ client = Campaigning::Client.find_by_name("Client One Company")
40
+ list = client.find_list_by_name "My Friends"
41
+ subscriber_list = list.get_all_active_subscribers
42
+ puts subscriber_list.inspect
43
+ assert subscriber_list.length > 0
44
+ end
45
+
46
+ def test_list_create
47
+ client = Campaigning::Client.find_by_name("Client One Company")
48
+ list = Campaigning::List.create!(
49
+ :clientID => client.clientID,
50
+ :title => "New list to test",
51
+ :unsubscribePage => "",
52
+ :confirmOptIn => false,
53
+ :confirmationSuccessPage => ""
54
+ )
55
+ assert list.listID != nil
56
+ end
57
+
58
+ def test_list_create_custom_field
59
+ client = Campaigning::Client.find_by_name("Client One Company")
60
+ list = client.find_list_by_name "My Friends"
61
+ result = list.create_custom_field!(
62
+ :fieldName => "Country" ,
63
+ :dataType => "MultiSelectOne",
64
+ :options => %w[Brazil Ireland England]
65
+ )
66
+ assert result.code == 0
67
+ end
68
+
69
+ def test_list_delete
70
+ result = Campaigning::List.delete!("916797045feddc92df10a4722f819771")
71
+ puts result.inspect
72
+ end
73
+
74
+ def test_list_delete_custom_field
75
+ client = Campaigning::Client.find_by_name("Client One Company")
76
+ list = client.find_list_by_name "My Friends"
77
+ result = list.delete_custom_field!("Country")
78
+ assert result.code == 0
79
+ end
80
+
81
+ def test_list_custom_fields
82
+ client = Campaigning::Client.find_by_name("Client One Company")
83
+ list = client.find_list_by_name "My Friends"
84
+ result = list.custom_fields
85
+ puts result.inspect
86
+ end
87
+
88
+ def test_list_details
89
+ client = Campaigning::Client.find_by_name("Client One Company")
90
+ list = client.find_list_by_name "My Friends"
91
+ result = list.details
92
+ puts result.inspect
93
+ end
94
+
95
+ def test_list_update
96
+ client = Campaigning::Client.find_by_name("Client One Company")
97
+ list = client.find_list_by_name "My Friends"
98
+ result = list.update!(
99
+ :title => "NEW TITLE : My new list created by ruby list.create",
100
+ :unsubscribePage => "",
101
+ :confirmOptIn => false,
102
+ :confirmationSuccessPage => ""
103
+ )
104
+ assert result.code == 0
105
+ end
106
+ end
@@ -0,0 +1,55 @@
1
+ require 'test_helper'
2
+
3
+ # Replace this API key with your own (http://www.campaignmonitor.com/api/)
4
+ CAMPAIGN_MONITOR_API_KEY = '__PUT_YOUR_API_KEY_HERE__'
5
+
6
+ class SubscriberTest < Test::Unit::TestCase
7
+
8
+
9
+ def setup
10
+ #Campaigning.set_endpoint_url "http://127.0.0.1:8088/mockapiSoap"
11
+ Campaigning.set_debug_mode(:on)
12
+ end
13
+
14
+ def test_subscriber_add
15
+ subscriber = Campaigning::Subscriber.new("robertf@test.com", "Robert Franklin")
16
+ response = subscriber.add!("ac52b645c048888a44c87b5f1ecf6b7d")
17
+ assert response.code == 0
18
+ end
19
+
20
+ def test_subscriber_add_with_custom_fields
21
+ subscriber = Campaigning::Subscriber.new("user_custon2@test.com", "Mr. Custon")
22
+ response = subscriber.add!("ac52b645c048888a44c87b5f1ecf6b7d", :CityName => "London", :SponsorName => "Some Sponsor from London")
23
+ assert response.code == 0
24
+ end
25
+
26
+ def test_subscriber_add_and_resubscribe
27
+ subscriber = Campaigning::Subscriber.new("norag@test.com", "Nora Green")
28
+ response = subscriber.add_and_resubscribe!("ac52b645c048888a44c87b5f1ecf6b7d")
29
+ assert response.code == 0
30
+ end
31
+
32
+
33
+ def test_subscriber_add_and_resubscribe_with_custom_fields
34
+ subscriber = Campaigning::Subscriber.new("user_custon@test.com", "Mr. Custon")
35
+ response = subscriber.add_and_resubscribe!("ac52b645c048888a44c87b5f1ecf6b7d", :CityName => "Dublin", :SponsorName => "Some Sponsor")
36
+ assert response.code == 0
37
+ end
38
+
39
+
40
+ def test_subscriber_unsubscribe
41
+ subscriber = Campaigning::Subscriber.new("user_to_test@test.com") # TODO: Change to get the Subscriber, not to CREATE a new one
42
+ response = subscriber.unsubscribe!("ac52b645c048888a44c87b5f1ecf6b7d")
43
+ puts response.inspect
44
+ assert response.code == 0
45
+ end
46
+
47
+
48
+ def test_subscriber_is_subscribed
49
+ subscriber = Campaigning::Subscriber.new("user_to_test@test.com") # TODO: Change to get the Subscriber, not to CREATE a new one
50
+ response = subscriber.is_subscribed?("ac52b645c048888a44c87b5f1ecf6b7d")
51
+ puts response.inspect
52
+ assert response == false
53
+ end
54
+
55
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gnumarcelo-campaigning
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.11.1
4
+ version: 0.12.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Marcelo Menezes
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2009-07-02 00:00:00 -07:00
12
+ date: 2009-07-03 00:00:00 -07:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
@@ -46,7 +46,11 @@ files:
46
46
  - lib/campaigning/soap/generated/defaultDriver.rb
47
47
  - lib/campaigning/soap/generated/defaultMappingRegistry.rb
48
48
  - lib/campaigning/subscriber.rb
49
+ - test/campaign_test.rb
49
50
  - test/campaigning_test.rb
51
+ - test/client_test.rb
52
+ - test/list_test.rb
53
+ - test/subscriber_test.rb
50
54
  - test/test_helper.rb
51
55
  has_rdoc: true
52
56
  homepage: http://github.com/gnumarcelo/campaigning
@@ -75,5 +79,9 @@ signing_key:
75
79
  specification_version: 3
76
80
  summary: TODO
77
81
  test_files:
82
+ - test/campaign_test.rb
78
83
  - test/campaigning_test.rb
84
+ - test/client_test.rb
85
+ - test/list_test.rb
86
+ - test/subscriber_test.rb
79
87
  - test/test_helper.rb