gnumarcelo-campaigning 0.12.1 → 0.14.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: 12
4
- :patch: 1
3
+ :minor: 14
4
+ :patch: 0
@@ -11,10 +11,11 @@ module Campaigning
11
11
  attr_accessor :sentDate
12
12
  attr_accessor :totalRecipients
13
13
 
14
- def initialize(campaignID = nil, subject = nil, sentDate = nil, totalRecipients = nil)
14
+ def initialize(campaignID = nil, subject = nil, sentDate = nil, totalRecipients = nil, opts={})
15
+ @apiKey = opts[:apiKey] || CAMPAIGN_MONITOR_API_KEY
15
16
  @campaignID = campaignID
16
- @subject = subject
17
- @sentDate = sentDate
17
+ @subject = subject
18
+ @sentDate = sentDate
18
19
  @totalRecipients = totalRecipients
19
20
  end
20
21
 
@@ -35,6 +36,7 @@ module Campaigning
35
36
  # * :textUrl - The URL of the Text content for the new campaign. If no unsubscribe link is found then one will be added automatically.
36
37
  # * :subscriberListIDs - An array of lists to send the campaign to. See http://www.campaignmonitor.com/api/required/#listid for more details.
37
38
  # * :listSegments - An array of Segment Names and their appropriate List ID s to send the campaign to.
39
+ # * :apiKey - optional API key to use to make request. Will use CAMPAIGN_MONITOR_API_KEY if not set.
38
40
  #
39
41
  #*Return*:
40
42
  #
@@ -43,7 +45,7 @@ module Campaigning
43
45
  #*Error*: An Exception containing the cause of the error will be raised.
44
46
  def self.create!(params)
45
47
  response = @@soap.createCampaign(
46
- :apiKey => CAMPAIGN_MONITOR_API_KEY,
48
+ :apiKey => params[:apiKey] || CAMPAIGN_MONITOR_API_KEY,
47
49
  :clientID => params[:clientID],
48
50
  :campaignName => params[:campaignName],
49
51
  :campaignSubject => params[:campaignSubject],
@@ -57,9 +59,9 @@ module Campaigning
57
59
  )
58
60
 
59
61
  campaign_id = handle_response response.campaign_CreateResult
60
- Campaign.new campaign_id
62
+ Campaign.new( campaign_id, nil, nil, nil, :apiKey=> (params[:apiKey] || CAMPAIGN_MONITOR_API_KEY) )
61
63
  end
62
-
64
+
63
65
  #Deletes an existing campaign.
64
66
  #
65
67
  #*Return*:
@@ -69,20 +71,23 @@ module Campaigning
69
71
  #
70
72
  #*Error*: An Exception containing the cause of the error will be raised.
71
73
  def delete!
72
- Campaign.delete!(@campaignID)
74
+ Campaign.delete!(@campaignID, :apiKey=> @apiKey)
73
75
  self.campaignID, self.subject, self.sentDate, self.totalRecipients = nil, nil, nil, nil
74
76
  end
75
77
 
76
78
  #Deletes an existing campaign.
77
79
  #
80
+ #Available _opts_ argument are:
81
+ # * :apiKey - optional API key to use to make request. Will use CAMPAIGN_MONITOR_API_KEY if not set.
82
+ #
78
83
  #*Return*:
79
84
  #
80
85
  #*Success*: Upon a successful call, this method will return a Campaigning::Result object wich consists of a +code+ and +message+ fields
81
86
  #containing a successful message.
82
87
  #
83
88
  #*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 => campaign_id)
89
+ def self.delete!(campaign_id, opts={})
90
+ response = @@soap.deleteCampaign(:apiKey => opts[:apiKey] || CAMPAIGN_MONITOR_API_KEY, :campaignID => campaign_id)
86
91
  handle_response response.campaign_DeleteResult
87
92
  end
88
93
 
@@ -96,7 +101,7 @@ module Campaigning
96
101
  #
97
102
  #*Error*: An Exception containing the cause of the error will be raised.
98
103
  def bounces
99
- response = @@soap.getCampaignBounces(:apiKey => CAMPAIGN_MONITOR_API_KEY, :campaignID => @campaignID )
104
+ response = @@soap.getCampaignBounces(:apiKey => @apiKey, :campaignID => @campaignID )
100
105
  handle_response response.campaign_GetBouncesResult
101
106
  end
102
107
 
@@ -108,10 +113,10 @@ module Campaigning
108
113
  #
109
114
  #*Error*: An Exception containing the cause of the error will be raised.
110
115
  def lists
111
- response = @@soap.getCampaignLists(:apiKey => CAMPAIGN_MONITOR_API_KEY, :campaignID => @campaignID )
116
+ response = @@soap.getCampaignLists(:apiKey => @apiKey, :campaignID => @campaignID )
112
117
  lists = handle_response response.campaign_GetListsResult
113
118
  lists.collect do |list|
114
- List.new(list.listID, list.name)
119
+ List.new(list.listID, list.name, :apiKey=> @apiKey)
115
120
  end
116
121
  end
117
122
 
@@ -125,7 +130,7 @@ module Campaigning
125
130
  #
126
131
  #*Error*: An Exception containing the cause of the error will be raised.
127
132
  def opens
128
- response = @@soap.getCampaignOpens(:apiKey => CAMPAIGN_MONITOR_API_KEY, :campaignID => @campaignID )
133
+ response = @@soap.getCampaignOpens(:apiKey => @apiKey, :campaignID => @campaignID )
129
134
  handle_response response.campaign_GetOpensResult
130
135
  end
131
136
 
@@ -150,7 +155,7 @@ module Campaigning
150
155
  #
151
156
  #*Error*: An Exception containing the cause of the error will be raised.
152
157
  def subscriber_clicks
153
- response = @@soap.getSubscriberClicks(:apiKey => CAMPAIGN_MONITOR_API_KEY, :campaignID => @campaignID )
158
+ response = @@soap.getSubscriberClicks(:apiKey => @apiKey, :campaignID => @campaignID )
154
159
  handle_response response.campaign_GetSubscriberClicksResult
155
160
  end
156
161
 
@@ -164,7 +169,7 @@ module Campaigning
164
169
  #
165
170
  #*Error*: An Exception containing the cause of the error will be raised.
166
171
  def summary
167
- response = @@soap.getCampaignSummary(:apiKey => CAMPAIGN_MONITOR_API_KEY, :campaignID => @campaignID )
172
+ response = @@soap.getCampaignSummary(:apiKey => @apiKey, :campaignID => @campaignID )
168
173
  handle_response response.campaign_GetSummaryResult
169
174
  end
170
175
 
@@ -177,7 +182,7 @@ module Campaigning
177
182
  #
178
183
  #*Error*: An Exception containing the cause of the error will be raised.
179
184
  def unsubscribes
180
- response = @@soap.getCampaignUnsubscribes(:apiKey => CAMPAIGN_MONITOR_API_KEY, :campaignID => @campaignID )
185
+ response = @@soap.getCampaignUnsubscribes(:apiKey => @apiKey, :campaignID => @campaignID )
181
186
  handle_response response.campaign_GetUnsubscribesResult
182
187
  end
183
188
 
@@ -199,13 +204,13 @@ module Campaigning
199
204
  #*Error*: An Exception containing the cause of the error will be raised.
200
205
  def send!(params)
201
206
  response = @@soap.sendCampaign(
202
- :apiKey => CAMPAIGN_MONITOR_API_KEY,
207
+ :apiKey => @apiKey,
203
208
  :campaignID => @campaignID,
204
209
  :confirmationEmail => params[:confirmationEmail],
205
210
  :sendDate => params[:sendDate]
206
211
  )
207
212
  handle_response response.campaign_SendResult
208
213
  end
209
-
214
+
210
215
  end
211
- end
216
+ end
@@ -1,4 +1,5 @@
1
1
  gem "soap4r", "~> 1.5.0"
2
+ require File.expand_path(File.dirname(__FILE__)) + '/template.rb'
2
3
  require File.expand_path(File.dirname(__FILE__)) + '/client.rb'
3
4
  require File.expand_path(File.dirname(__FILE__)) + '/campaign.rb'
4
5
  require File.expand_path(File.dirname(__FILE__)) + '/subscriber.rb'
@@ -12,21 +13,30 @@ module Campaigning
12
13
  #Gets the server system time for your time zone.
13
14
  #This is handy for when you are syncing your {Campaign Monitor}[http://www.campaignmonitor.com] lists with some other in-house list,
14
15
  #allowing you accurately determine the time on our server when you carry out the synchronization.
15
- def self.system_date
16
- response = @@soap.getSystemDate(:apiKey => CAMPAIGN_MONITOR_API_KEY)
16
+ #
17
+ #Aviable _opts_ arguments are:
18
+ # * :apiKey - optional API key to use to make request. Will use CAMPAIGN_MONITOR_API_KEY if not set.
19
+ def self.system_date(opts={})
20
+ response = @@soap.getSystemDate(:apiKey => opts[:apiKey] || CAMPAIGN_MONITOR_API_KEY)
17
21
  dateTime = handle_response response.user_GetSystemDateResult
18
22
  end
19
23
 
20
24
  ##
21
25
  #This method returns an Array of Strings representing all the available timezones.
22
- def self.timezones
23
- handle_response @@soap.getTimezones(:apiKey => CAMPAIGN_MONITOR_API_KEY).user_GetTimezonesResult
26
+ #
27
+ #Aviable _opts_ arguments are:
28
+ # * :apiKey - optional API key to use to make request. Will use CAMPAIGN_MONITOR_API_KEY if not set.
29
+ def self.timezones(opts={})
30
+ handle_response @@soap.getTimezones(:apiKey => opts[:apiKey] || CAMPAIGN_MONITOR_API_KEY).user_GetTimezonesResult
24
31
  end
25
32
 
26
33
  ##
27
34
  #This method returns an Array of Strings representing all the available countries.
28
- def self.countries
29
- response = @@soap.getCountries(:apiKey => CAMPAIGN_MONITOR_API_KEY)
35
+ #
36
+ #Aviable _opts_ arguments are:
37
+ # * :apiKey - optional API key to use to make request. Will use CAMPAIGN_MONITOR_API_KEY if not set.
38
+ def self.countries(opts={})
39
+ response = @@soap.getCountries(:apiKey => opts[:apiKey] || CAMPAIGN_MONITOR_API_KEY)
30
40
  dateTime = handle_response response.user_GetCountriesResult
31
41
  end
32
42
 
@@ -8,10 +8,25 @@ module Campaigning
8
8
  attr_accessor :clientID
9
9
  attr_accessor :name
10
10
 
11
- def initialize(clientID = nil, name = nil)
12
- @clientID = clientID
13
- @name = name
11
+ def initialize(clientID = nil, name = nil, opts={})
12
+ @apiKey = opts[:apiKey] || CAMPAIGN_MONITOR_API_KEY
13
+ @clientID = clientID
14
+ @name = name
14
15
  end
16
+
17
+ #Gets a list of all templates for a client.
18
+ #
19
+ #*Return*:
20
+ #
21
+ #*Success*: Upon a successful call, this method will return a collection of Campaigning::Template objects.
22
+ #
23
+ #*Error*: An Exception containing the cause of the error will be raised.
24
+ def templates
25
+ response = @@soap.getClientTemplates(:apiKey => @apiKey, :clientID => @clientID)
26
+ templates = handle_response response.client_GetTemplatesResult
27
+ templates.collect {|template| Template.new(template.templateID, template.name, template.previewURL, template.screenshotURL, :apiKey=> @apiKey)}
28
+ end
29
+
15
30
 
16
31
  #Gets a list of all subscriber lists for a client.
17
32
  #
@@ -21,9 +36,9 @@ module Campaigning
21
36
  #
22
37
  #*Error*: An Exception containing the cause of the error will be raised.
23
38
  def lists
24
- response = @@soap.getClientLists(:apiKey => CAMPAIGN_MONITOR_API_KEY, :clientID => @clientID)
39
+ response = @@soap.getClientLists(:apiKey => @apiKey, :clientID => @clientID)
25
40
  lists = handle_response response.client_GetListsResult
26
- lists.collect {|list| List.new(list.listID, list.name)}
41
+ lists.collect {|list| List.new(list.listID, list.name, :apiKey=> @apiKey)}
27
42
  end
28
43
 
29
44
  #This method find a List by a given name
@@ -43,6 +58,9 @@ module Campaigning
43
58
 
44
59
  #This method find a Client by a given name
45
60
  #
61
+ #Aviable _opts_ arguments are:
62
+ # * :apiKey - optional API key to use to make request. Will use CAMPAIGN_MONITOR_API_KEY if not set.
63
+ #
46
64
  #*Return*:
47
65
  #
48
66
  #Client FOUND: If it found any client with the given name it will return a Campaigning::Client object containing the found client.
@@ -52,23 +70,26 @@ module Campaigning
52
70
  #*Error*: An Exception containing the cause of the error will be raised.
53
71
  #-- TODO: Refactor this method and increase performance?
54
72
  #-- TODO: Tha campaign monitor permit two users with the same name, what to do?
55
- def self.find_by_name(name)
56
- client_list = Client.get_all_clients
73
+ def self.find_by_name(name, opts={})
74
+ client_list = Client.get_all_clients(opts)
57
75
  client_found = client_list.find {|client| name == client.name}
58
- Client.new(client_found.clientID, client_found.name) if client_found
76
+ Client.new(client_found.clientID, client_found.name, :apiKey=> opts[:apiKey]) if client_found
59
77
  end
60
78
 
61
79
  #Gets all clients for a given user (CAMPAIGN_MONITOR_API_KEY).
62
80
  #
81
+ #Aviable _opts_ arguments are:
82
+ # * :apiKey - optional API key to use to make request. Will use CAMPAIGN_MONITOR_API_KEY if not set.
83
+ #
63
84
  #*Return*:
64
85
  #
65
86
  #*Success*: Upon a successful call, this method will return a collection of Campaigning::Client objects.
66
87
  #
67
88
  #*Error*: An Exception containing the cause of the error will be raised.
68
- def self.get_all_clients
69
- response = @@soap.getClients(:apiKey => CAMPAIGN_MONITOR_API_KEY)
70
- clients = handle_response response.user_GetClientsResult
71
- clients.collect {|client| Client.new(client.clientID, client.name)}
89
+ def self.get_all_clients(opts={})
90
+ response = @@soap.getClients(:apiKey => opts[:apiKey] || CAMPAIGN_MONITOR_API_KEY)
91
+ clients = handle_response response.user_GetClientsResult
92
+ clients.collect {|client| Client.new(client.clientID, client.name, :apiKey=> opts[:apiKey])}
72
93
  end
73
94
 
74
95
  #This method creates a brand new client with no access to the application.
@@ -83,6 +104,8 @@ module Campaigning
83
104
  # using the API procedure Campaigning.countries
84
105
  # * :timezone - Client timezone for tracking and reporting data. A valid timezone list is available here or by using the API
85
106
  # procedure Campaigning.timezones.
107
+ # * :apiKey - optional API key to use to make request. Will use CAMPAIGN_MONITOR_API_KEY if not set.
108
+ #
86
109
  #*Return*:
87
110
  #
88
111
  #*Success*: Upon a successful call, this method will return a Campaigning::Client object representing the newly created client.
@@ -90,14 +113,14 @@ module Campaigning
90
113
  #*Error*: An Exception containing the cause of the error will be raised.
91
114
  def self.create!(params)
92
115
  response = @@soap.createClient(
93
- :apiKey => CAMPAIGN_MONITOR_API_KEY,
116
+ :apiKey => params[:apiKey] || CAMPAIGN_MONITOR_API_KEY,
94
117
  :companyName => params[:companyName],
95
118
  :contactName => params[:contactName],
96
119
  :emailAddress => params[:emailAddress],
97
120
  :country => params[:country],
98
121
  :timezone => params[:timezone]
99
122
  )
100
- Client.new( handle_response(response.client_CreateResult), params[:companyName] )
123
+ Client.new( handle_response(response.client_CreateResult), params[:companyName], :apiKey=> params[:apiKey] )
101
124
  end
102
125
 
103
126
  #Deletes a client from your account.
@@ -109,21 +132,24 @@ module Campaigning
109
132
  #
110
133
  #*Error*: An Exception containing the cause of the error will be raised.
111
134
  def delete!
112
- response = Client.delete!(@clientID)
135
+ response = Client.delete!(@clientID, :apiKey=> @apiKey)
113
136
  self.clientID, self.name = nil
114
137
  response
115
138
  end
116
139
 
117
140
  #Deletes a client from your account.
118
141
  #
142
+ #Aviable _opts_ arguments are:
143
+ # * :apiKey - optional API key to use to make request. Will use CAMPAIGN_MONITOR_API_KEY if not set.
144
+ #
119
145
  #*Return*:
120
146
  #
121
147
  #*Success*: Upon a successful call, this method will return a Campaigning::Result object wich consists of a +code+ and +message+ fields
122
148
  #containing a successful message.
123
149
  #
124
150
  #*Error*: An Exception containing the cause of the error will be raised.
125
- def self.delete!(client_id)
126
- response = @@soap.deleteClient(:apiKey => CAMPAIGN_MONITOR_API_KEY, :clientID => client_id)
151
+ def self.delete!(client_id, opts={})
152
+ response = @@soap.deleteClient(:apiKey => opts[:apiKey] || CAMPAIGN_MONITOR_API_KEY, :clientID => client_id)
127
153
  handle_response response.client_DeleteResult
128
154
  end
129
155
 
@@ -136,7 +162,7 @@ module Campaigning
136
162
  #
137
163
  #*Error*: An Exception containing the cause of the error will be raised.
138
164
  def segments # TODO: Verify the type return for this method.
139
- response = @@soap.getClientSegments(:apiKey => CAMPAIGN_MONITOR_API_KEY, :clientID => @clientID )
165
+ response = @@soap.getClientSegments(:apiKey => @apiKey, :clientID => @clientID )
140
166
  handle_response response.client_GetSegmentsResult
141
167
  end
142
168
 
@@ -167,10 +193,10 @@ module Campaigning
167
193
  #
168
194
  #*Error*: An Exception containing the cause of the error will be raised.
169
195
  def campaigns
170
- response = @@soap.getClientCampaigns(:apiKey => CAMPAIGN_MONITOR_API_KEY, :clientID => @clientID )
196
+ response = @@soap.getClientCampaigns(:apiKey => @apiKey, :clientID => @clientID )
171
197
  campaign_list = handle_response response.client_GetCampaignsResult
172
198
  campaign_list.collect do |campaign|
173
- Campaign.new(campaign.campaignID, campaign.subject, campaign.sentDate, campaign.totalRecipients)
199
+ Campaign.new(campaign.campaignID, campaign.subject, campaign.sentDate, campaign.totalRecipients, :apiKey=> @apiKey)
174
200
  end
175
201
  end
176
202
 
@@ -204,7 +230,7 @@ module Campaigning
204
230
  #
205
231
  #*Error*: An Exception containing the cause of the error will be raised.
206
232
  def details
207
- response = @@soap.getClientDetail(:apiKey => CAMPAIGN_MONITOR_API_KEY, :clientID => @clientID )
233
+ response = @@soap.getClientDetail(:apiKey => @apiKey, :clientID => @clientID )
208
234
  handle_response response.client_GetDetailResult
209
235
  end
210
236
 
@@ -216,7 +242,7 @@ module Campaigning
216
242
  #
217
243
  #*Error*: An Exception containing the cause of the error will be raised.
218
244
  def suppression_list
219
- response = @@soap.getClientSuppressionList(:apiKey => CAMPAIGN_MONITOR_API_KEY, :clientID => @clientID )
245
+ response = @@soap.getClientSuppressionList(:apiKey => @apiKey, :clientID => @clientID )
220
246
  handle_response response.client_GetSuppressionListResult
221
247
  end
222
248
 
@@ -245,7 +271,7 @@ module Campaigning
245
271
  # rate. Further detail is available at http://help.campaignmonitor.com/topic.aspx?t=118.
246
272
  # * :designAndSpamTestFee - Expressed in the chosen currency's major unit (for example, sending "10" means "$10" if USD is used). Only required
247
273
  # if BillingType is set to ClientPaysWithMarkup and client has access to design and spam tests, in which case the fee
248
- # should be equal to or higher than the standard rate (identical to the standard DeliveryFee for that currency).
274
+ # should be equal to or higher than the standard rate (identical to the standard DeliveryFee for that currency).
249
275
  #
250
276
  #
251
277
  #
@@ -259,7 +285,7 @@ module Campaigning
259
285
  #*Error*: An Exception containing the cause of the error will be raised.
260
286
  def update_access_and_billing!(params)
261
287
  response = @@soap.updateClientAccessAndBilling(
262
- :apiKey => CAMPAIGN_MONITOR_API_KEY,
288
+ :apiKey => @apiKey,
263
289
  :clientID => @clientID,
264
290
  :accessLevel => params[:accessLevel],
265
291
  :username => params.fetch(:username, ""),
@@ -293,7 +319,7 @@ module Campaigning
293
319
  #*Error*: An Exception containing the cause of the error will be raised.
294
320
  def update_basics!(params)
295
321
  response = @@soap.updateClientBasics(
296
- :apiKey => CAMPAIGN_MONITOR_API_KEY,
322
+ :apiKey => @apiKey,
297
323
  :clientID => @clientID,
298
324
  :companyName => params[:companyName],
299
325
  :contactName => params[:contactName],
@@ -8,7 +8,8 @@ module Campaigning
8
8
  attr_accessor :listID
9
9
  attr_accessor :name
10
10
 
11
- def initialize(listID = nil, name = nil)
11
+ def initialize(listID = nil, name = nil, opts={})
12
+ @apiKey = opts[:apiKey] || CAMPAIGN_MONITOR_API_KEY
12
13
  @listID = listID
13
14
  @name = name
14
15
  end
@@ -24,6 +25,7 @@ module Campaigning
24
25
  # the help documentation for more details of what this means.
25
26
  # * :confirmationSuccessPage - Successful email confirmations will be redirected to this URL. Ignored if ConfirmOptIn
26
27
  # is false. If left blank or omitted a generic confirmation page is used.
28
+ # * :apiKey - optional API key to use to make request. Will use CAMPAIGN_MONITOR_API_KEY if not set.
27
29
  #*Return*:
28
30
  #
29
31
  #*Success*: Upon a successful call, this method will return a Campaigning::List object representing the newly created list.
@@ -31,7 +33,7 @@ module Campaigning
31
33
  #*Error*: An Exception containing the cause of the error will be raised.
32
34
  def self.create!(params)
33
35
  response = @@soap.createList(
34
- :apiKey => CAMPAIGN_MONITOR_API_KEY,
36
+ :apiKey => params[:apiKey] || CAMPAIGN_MONITOR_API_KEY,
35
37
  :clientID => params[:clientID],
36
38
  :title => params[:title],
37
39
  :unsubscribePage => params.fetch(:unsubscribePage, ""),
@@ -39,7 +41,7 @@ module Campaigning
39
41
  :confirmationSuccessPage => params.fetch(:confirmationSuccessPage, "")
40
42
  )
41
43
  new_list_id = handle_response response.list_CreateResult
42
- List.new(new_list_id, params[:title])
44
+ List.new(new_list_id, params[:title], :apiKey=> params[:apiKey])
43
45
  end
44
46
 
45
47
  #Creates a new custom field for a list
@@ -58,7 +60,7 @@ module Campaigning
58
60
  #*Error*: An Exception containing the cause of the error will be raised.
59
61
  def create_custom_field!(params)
60
62
  response = @@soap.createListCustomField(
61
- :apiKey => CAMPAIGN_MONITOR_API_KEY,
63
+ :apiKey => @apiKey,
62
64
  :listID => @listID,
63
65
  :fieldName => params[:fieldName],
64
66
  :dataType => params[:dataType],
@@ -76,20 +78,23 @@ module Campaigning
76
78
  #
77
79
  #*Error*: An Exception containing the cause of the error will be raised.
78
80
  def delete!
79
- List.delete!(@listID)
81
+ List.delete!(@listID, :apiKey=> @apiKey)
80
82
  self.listID, self.name = nil, nil
81
83
  end
82
84
 
83
85
  #Deletes a list
84
86
  #
87
+ #Aviable _opts_ arguments are:
88
+ # * :apiKey - optional API key to use to make request. Will use CAMPAIGN_MONITOR_API_KEY if not set.
89
+ #
85
90
  #*Return*:
86
91
  #
87
92
  #*Success*: Upon a successful call, this method will return a Campaigning::Result object wich consists of a +code+ and +message+ fields
88
93
  #containing a successful message.
89
94
  #
90
95
  #*Error*: An Exception containing the cause of the error will be raised.
91
- def self.delete!(list_id)
92
- response = @@soap.deleteList(:apiKey => CAMPAIGN_MONITOR_API_KEY, :listID => list_id)
96
+ def self.delete!(list_id, opts={})
97
+ response = @@soap.deleteList(:apiKey => opts[:apiKey] || CAMPAIGN_MONITOR_API_KEY, :listID => list_id)
93
98
  handle_response response.list_DeleteResult
94
99
  end
95
100
 
@@ -102,7 +107,7 @@ module Campaigning
102
107
  #
103
108
  #*Error*: An Exception containing the cause of the error will be raised.
104
109
  def delete_custom_field!(key)
105
- response = @@soap.deleteListCustomField(:apiKey => CAMPAIGN_MONITOR_API_KEY, :listID => @listID, :key => '['+key+']')
110
+ response = @@soap.deleteListCustomField(:apiKey => @apiKey, :listID => @listID, :key => '['+key+']')
106
111
  handle_response response.list_DeleteCustomFieldResult
107
112
  end
108
113
 
@@ -115,7 +120,7 @@ module Campaigning
115
120
  #
116
121
  #*Error*: An Exception containing the cause of the error will be raised.
117
122
  def custom_fields
118
- response = @@soap.getListCustomFields(:apiKey => CAMPAIGN_MONITOR_API_KEY, :listID => @listID)
123
+ response = @@soap.getListCustomFields(:apiKey => @apiKey, :listID => @listID)
119
124
  handle_response response.list_GetCustomFieldsResult
120
125
  end
121
126
 
@@ -128,7 +133,7 @@ module Campaigning
128
133
  #
129
134
  #*Error*: An Exception containing the cause of the error will be raised.
130
135
  def details
131
- response = @@soap.getListDetail(:apiKey => CAMPAIGN_MONITOR_API_KEY, :listID => @listID)
136
+ response = @@soap.getListDetail(:apiKey => @apiKey, :listID => @listID)
132
137
  handle_response response.list_GetDetailResult
133
138
  end
134
139
 
@@ -155,7 +160,7 @@ module Campaigning
155
160
  #*Error*: An Exception containing the cause of the error will be raised.
156
161
  def find_active_subscribers(joined_at)
157
162
  response = @@soap.getSubscribers(
158
- :apiKey => CAMPAIGN_MONITOR_API_KEY,
163
+ :apiKey => @apiKey,
159
164
  :listID => @listID,
160
165
  :date =>joined_at.strftime('%Y-%m-%d %H:%M:%S')
161
166
  )
@@ -175,7 +180,7 @@ module Campaigning
175
180
  #*Error*: An Exception containing the cause of the error will be raised.
176
181
  def find_unsubscribed(unjoined_at)
177
182
  response = @@soap.getUnsubscribed(
178
- :apiKey => CAMPAIGN_MONITOR_API_KEY,
183
+ :apiKey => @apiKey,
179
184
  :listID => @listID,
180
185
  :date => unjoined_at.strftime('%Y-%m-%d %H:%M:%S') # TODO: Move that to a helper method
181
186
  )
@@ -192,7 +197,7 @@ module Campaigning
192
197
  #*Error*: An Exception containing the cause of the error will be raised.
193
198
  def find_single_subscriber(email_address) # TODO: Create a mehod to handle with custom fields returned like (names from "State Name" to "state_name")
194
199
  response = @@soap.getSingleSubscriber(
195
- :apiKey => CAMPAIGN_MONITOR_API_KEY,
200
+ :apiKey => @apiKey,
196
201
  :listID => @listID,
197
202
  :emailAddress => email_address
198
203
  )
@@ -218,7 +223,7 @@ module Campaigning
218
223
  #*Error*: An Exception containing the cause of the error will be raised.
219
224
  def update!(params)
220
225
  response = @@soap.updateList(
221
- :apiKey => CAMPAIGN_MONITOR_API_KEY,
226
+ :apiKey => @apiKey,
222
227
  :listID => @listID,
223
228
  :title => params[:title],
224
229
  :unsubscribePage => params.fetch(:unsubscribePage, ""),