Empact-campaign_monitor 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
data/CHANGELOG ADDED
@@ -0,0 +1,3 @@
1
+ *0.1.0*
2
+
3
+ * Initial Release
data/README.rdoc ADDED
@@ -0,0 +1,22 @@
1
+ = campaign_monitor
2
+
3
+ This library provides access to the Campaign Monitor API (http://www.campaignmonitor.com/api)
4
+
5
+ == Pre-requisites
6
+
7
+ An account with Campaign Monitor and the API Key. Accounts are free and can be obtained from
8
+ http://www.campaignmonitor.com
9
+
10
+ == Resources
11
+
12
+ Install
13
+
14
+ * gem install campaign_monitor
15
+
16
+ Bugtracking
17
+
18
+ * http://jordanbrock.lighthouseapp.com/projects/13212/home
19
+
20
+ Git Repository
21
+
22
+ * http://github.com/jordanbrock/campaign-monitor-ruby
data/Rakefile ADDED
@@ -0,0 +1,29 @@
1
+ require 'rubygems'
2
+ require 'rake/gempackagetask'
3
+ require 'rake/testtask'
4
+ require 'rake/rdoctask'
5
+
6
+ # read the contents of the gemspec, eval it, and assign it to 'spec'
7
+ # this lets us maintain all gemspec info in one place. Nice and DRY.
8
+ spec = eval(IO.read("campaign-monitor-ruby.gemspec"))
9
+
10
+ Rake::GemPackageTask.new(spec) do |pkg|
11
+ pkg.gem_spec = spec
12
+ end
13
+
14
+ task :install => [:package] do
15
+ sh %{sudo gem install pkg/#{spec.name}-#{spec.version}}
16
+ end
17
+
18
+ Rake::TestTask.new do |t|
19
+ t.libs << "test"
20
+ t.test_files = FileList['test/test*.rb']
21
+ t.verbose = true
22
+ end
23
+
24
+ Rake::RDocTask.new do |rd|
25
+ rd.main = "README.rdoc"
26
+ rd.rdoc_files.include("README.rdoc", "lib/**/*.rb")
27
+ rd.rdoc_dir = 'doc'
28
+ rd.options = spec.rdoc_options
29
+ end
data/TODO ADDED
@@ -0,0 +1,3 @@
1
+ 10th May, 2006
2
+ * Add tests
3
+ * Add ability to have multiple user-defined fields.
@@ -0,0 +1,56 @@
1
+ Gem::Specification.new do |s|
2
+ s.platform = Gem::Platform::RUBY
3
+ s.name = 'campaign_monitor'
4
+ s.version = "0.1.1"
5
+ s.summary = 'Provides access to the Campaign Monitor API'
6
+ s.description = <<-EOF
7
+ A simple wrapper class that provides basic access to the Campaign Monitor API
8
+ EOF
9
+ s.author = 'Jordan Brock'
10
+ s.email = 'jordan@spintech.com.au'
11
+ s.rubyforge_project = 'campaignmonitor'
12
+ s.homepage = 'http://spintech.com.au/projects/plugins/campaign_monitor'
13
+
14
+ s.requirements << 'none'
15
+ s.require_path = 'lib'
16
+ s.rubyforge_project = 'campaignmonitor'
17
+
18
+ s.files = [
19
+ 'LICENSE',
20
+ 'CHANGELOG',
21
+ 'init.rb',
22
+ 'Rakefile',
23
+ 'test/campaign_monitor_test.rb',
24
+ 'TODO',
25
+ 'lib/campaign_monitor.rb',
26
+ 'lib/campaign_monitor/campaign.rb',
27
+ 'lib/campaign_monitor/list.rb',
28
+ 'lib/campaign_monitor/client.rb',
29
+ 'lib/campaign_monitor/result.rb',
30
+ 'lib/campaign_monitor/subscriber.rb',
31
+ 'README.rdoc',
32
+ 'install.rb',
33
+ 'campaign-monitor-ruby.gemspec',
34
+ 'Manifest'
35
+ ]
36
+
37
+ s.test_file = 'test/campaign_monitor_test.rb'
38
+
39
+ s.has_rdoc = true
40
+ s.rdoc_options << '--line-numbers' << '--inline-source' <<
41
+ '--title' << 'Campaign-monitor-ruby' <<
42
+ '--main' << 'README.rdoc'
43
+
44
+ s.extra_rdoc_files = [
45
+ 'LICENSE',
46
+ 'CHANGELOG',
47
+ 'TODO',
48
+ 'lib/campaign_monitor.rb',
49
+ 'lib/campaign_monitor/campaign.rb',
50
+ 'lib/campaign_monitor/list.rb',
51
+ 'lib/campaign_monitor/client.rb',
52
+ 'lib/campaign_monitor/result.rb',
53
+ 'lib/campaign_monitor/subscriber.rb',
54
+ 'README.rdoc'
55
+ ]
56
+ end
data/init.rb ADDED
@@ -0,0 +1 @@
1
+ require 'campaign_monitor'
data/install.rb ADDED
File without changes
@@ -0,0 +1,220 @@
1
+ # CampaignMonitor
2
+ # A wrapper class to access the Campaign Monitor API. Written using the wonderful
3
+ # Flickr interface by Scott Raymond as a guide on how to access remote web services
4
+ #
5
+ # For more information on the Campaign Monitor API, visit http://campaignmonitor.com/api
6
+ #
7
+ # Author:: Jordan Brock <jordan@spintech.com.au>
8
+ # Copyright:: Copyright (c) 2006 Jordan Brock <jordan@spintech.com.au>
9
+ # License:: MIT <http://www.opensource.org/licenses/mit-license.php>
10
+ #
11
+ # USAGE:
12
+ # require 'campaign_monitor'
13
+ # cm = CampaignMonitor.new(API_KEY) # creates a CampaignMonitor object
14
+ # # Can set CAMPAIGN_MONITOR_API_KEY in environment.rb
15
+ # cm.clients # Returns an array of clients associated with
16
+ # # the user account
17
+ # cm.campaigns(client_id)
18
+ # cm.lists(client_id)
19
+ # cm.add_subscriber(list_id, email, name)
20
+ #
21
+ # CLIENT
22
+ # client = Client.new(client_id)
23
+ # client.lists
24
+ # client.campaigns
25
+ #
26
+ # LIST
27
+ # list = List.new(list_id)
28
+ # list.add_subscriber(email, name)
29
+ # list.remove_subscriber(email)
30
+ # list.active_subscribers(date)
31
+ # list.unsubscribed(date)
32
+ # list.bounced(date)
33
+ #
34
+ # CAMPAIGN
35
+ # campaign = Campaign.new(campaign_id)
36
+ # campaign.clicks
37
+ # campaign.opens
38
+ # campaign.bounces
39
+ # campaign.unsubscribes
40
+ # campaign.number_recipients
41
+ # campaign.number_clicks
42
+ # campaign.number_opens
43
+ # campaign.number_bounces
44
+ # campaign.number_unsubscribes
45
+ #
46
+ #
47
+ # SUBSCRIBER
48
+ # subscriber = Subscriber.new(email)
49
+ # subscriber.add(list_id)
50
+ # subscriber.unsubscribe(list_id)
51
+ #
52
+ # Data Types
53
+ # SubscriberBounce
54
+ # SubscriberClick
55
+ # SubscriberOpen
56
+ # SubscriberUnsubscribe
57
+ # Result
58
+ #
59
+
60
+ require 'rubygems'
61
+ require 'cgi'
62
+ require 'net/http'
63
+ require 'xmlsimple'
64
+ require 'date'
65
+
66
+ Dir[File.join(File.dirname(__FILE__), 'campaign_monitor/*.rb')].each do |f|
67
+ require f
68
+ end
69
+
70
+ class CampaignMonitor
71
+ # Replace this API key with your own (http://www.campaignmonitor.com/api/)
72
+ def initialize(api_key=CAMPAIGN_MONITOR_API_KEY)
73
+ @api_key = api_key
74
+ @host = 'http://app.campaignmonitor.com'
75
+ @api = '/api/api.asmx/'
76
+ end
77
+
78
+ # Takes a CampaignMonitor API method name and set of parameters;
79
+ # returns an XmlSimple object with the response
80
+ def request(method, params)
81
+ response = XmlSimple.xml_in(http_get(request_url(method, params)), { 'keeproot' => false,
82
+ 'forcearray' => %w[List Campaign Subscriber Client SubscriberOpen SubscriberUnsubscribe SubscriberClick SubscriberBounce],
83
+ 'noattr' => true })
84
+ response.delete('d1p1:type')
85
+ response
86
+ end
87
+
88
+ # Takes a CampaignMonitor API method name and set of parameters; returns the correct URL for the REST API.
89
+ def request_url(method, params={})
90
+ url = "#{@host}#{@api}/#{method}?ApiKey=#{@api_key}"
91
+ params.each_pair do |key, val|
92
+ url += "&#{key}=" + CGI::escape(val.to_s)
93
+ end
94
+ url
95
+ end
96
+
97
+ # Does an HTTP GET on a given URL and returns the response body
98
+ def http_get(url)
99
+ Net::HTTP.get_response(URI.parse(url)).body.to_s
100
+ end
101
+
102
+ # By overriding the method_missing method, it is possible to easily support all of the methods
103
+ # available in the API
104
+ def method_missing(method_id, params = {})
105
+ request(method_id.id2name.gsub(/_/, '.'), params)
106
+ end
107
+
108
+ # Returns an array of Client objects associated with the API Key
109
+ #
110
+ # Example
111
+ # @cm = CampaignMonitor.new()
112
+ # @clients = @cm.clients
113
+ #
114
+ # for client in @clients
115
+ # puts client.name
116
+ # end
117
+ def clients
118
+ response = User_GetClients()
119
+ return [] if response.empty?
120
+ unless response["Code"].to_i != 0
121
+ response["Client"].collect{|c| Client.new(c["ClientID"].to_i, c["Name"])}
122
+ else
123
+ raise response["Code"] + " - " + response["Message"]
124
+ end
125
+ end
126
+
127
+ # Returns an array of Campaign objects associated with the specified Client ID
128
+ #
129
+ # Example
130
+ # @cm = CampaignMonitor.new()
131
+ # @campaigns = @cm.campaigns(12345)
132
+ #
133
+ # for campaign in @campaigns
134
+ # puts campaign.subject
135
+ # end
136
+ def campaigns(client_id)
137
+ response = Client_GetCampaigns("ClientID" => client_id)
138
+ return [] if response.empty?
139
+ unless response["Code"].to_i != 0
140
+ response["Campaign"].collect{|c| Campaign.new(c["CampaignID"].to_i, c["Subject"], c["SentDate"], c["TotalRecipients"].to_i)}
141
+ else
142
+ raise response["Code"] + " - " + response["Message"]
143
+ end
144
+ end
145
+
146
+ # Returns an array of Subscriber Lists for the specified Client ID
147
+ #
148
+ # Example
149
+ # @cm = CampaignMonitor.new()
150
+ # @lists = @cm.lists(12345)
151
+ #
152
+ # for list in @lists
153
+ # puts list.name
154
+ # end
155
+ def lists(client_id)
156
+ response = Client_GetLists("ClientID" => client_id)
157
+ return [] if response.empty?
158
+ unless response["Code"].to_i != 0
159
+ response["List"].collect{|l| List.new(l["ListID"].to_i, l["Name"])}
160
+ else
161
+ raise response["Code"] + " - " + response["Message"]
162
+ end
163
+ end
164
+
165
+ # A quick method of adding a subscriber to a list. Returns a Result object
166
+ #
167
+ # Example
168
+ # @cm = CampaignMonitor.new()
169
+ # result = @cm.add_subscriber(12345, "ralph.wiggum@simpsons.net", "Ralph Wiggum")
170
+ #
171
+ # if result.succeeded?
172
+ # puts "Subscriber Added to List"
173
+ # end
174
+ def add_subscriber(list_id, email, name)
175
+ Result.new(Subscriber_Add("ListID" => list_id, "Email" => email, "Name" => name))
176
+ end
177
+
178
+ # Encapsulates
179
+ class SubscriberBounce
180
+ attr_reader :email_address, :bounce_type, :list_id
181
+
182
+ def initialize(email_address, list_id, bounce_type)
183
+ @email_address = email_address
184
+ @bounce_type = bounce_type
185
+ @list_id = list_id
186
+ end
187
+ end
188
+
189
+ # Encapsulates
190
+ class SubscriberOpen
191
+ attr_reader :email_address, :list_id, :opens
192
+
193
+ def initialize(email_address, list_id, opens)
194
+ @email_address = email_address
195
+ @list_id = list_id
196
+ @opens = opens
197
+ end
198
+ end
199
+
200
+ # Encapsulates
201
+ class SubscriberClick
202
+ attr_reader :email_address, :list_id, :clicked_links
203
+
204
+ def initialize(email_address, list_id, clicked_links)
205
+ @email_address = email_address
206
+ @list_id = list_id
207
+ @clicked_links = clicked_links
208
+ end
209
+ end
210
+
211
+ # Encapsulates
212
+ class SubscriberUnsubscribe
213
+ attr_reader :email_address, :list_id
214
+
215
+ def initialize(email_address, list_id)
216
+ @email_address = email_address
217
+ @list_id = list_id
218
+ end
219
+ end
220
+ end
@@ -0,0 +1,129 @@
1
+ class CampaignMonitor
2
+ # Provides access to the information about a campaign
3
+ class Campaign
4
+ attr_reader :id, :subject, :sent_date, :total_recipients
5
+
6
+ def initialize(id=nil, subject=nil, sent_date=nil, total_recipients=nil)
7
+ @id = id
8
+ @subject = subject
9
+ @sent_date = sent_date
10
+ @total_recipients = total_recipients
11
+ @cm_client = CampaignMonitor.new
12
+ end
13
+
14
+ # Example
15
+ # @campaign = Campaign.new(12345)
16
+ # @subscriber_opens = @campaign.opens
17
+ #
18
+ # for subscriber in @subscriber_opens
19
+ # puts subscriber.email
20
+ # end
21
+ def opens
22
+ response = @cm_client.Campaign_GetOpens("CampaignID" => @id)
23
+ return [] if response.empty?
24
+ unless response["Code"].to_i != 0
25
+ response["SubscriberOpen"].collect{|s| SubscriberOpen.new(s["EmailAddress"], s["ListID"].to_i, s["NumberOfOpens"])}
26
+ else
27
+ raise response["Code"] + " - " + response["Message"]
28
+ end
29
+ end
30
+
31
+ # Example
32
+ # @campaign = Campaign.new(12345)
33
+ # @subscriber_bounces = @campaign.bounces
34
+ #
35
+ # for subscriber in @subscriber_bounces
36
+ # puts subscriber.email
37
+ # end
38
+ def bounces
39
+ response = @cm_client.Campaign_GetBounces("CampaignID"=> @id)
40
+ return [] if response.empty?
41
+ unless response["Code"].to_i != 0
42
+ response["SubscriberBounce"].collect{|s| SubscriberBounce.new(s["EmailAddress"], s["ListID"].to_i, s["BounceType"])}
43
+ else
44
+ raise response["Code"] + " - " + response["Message"]
45
+ end
46
+ end
47
+
48
+ # Example
49
+ # @campaign = Campaign.new(12345)
50
+ # @subscriber_clicks = @campaign.clicks
51
+ #
52
+ # for subscriber in @subscriber_clicks
53
+ # puts subscriber.email
54
+ # end
55
+ def clicks
56
+ response = @cm_client.Campaign_GetSubscriberClicks("CampaignID" => @id)
57
+ return [] if response.empty?
58
+ unless response["Code"].to_i != 0
59
+ response["SubscriberClick"].collect{|s| SubscriberClick.new(s["EmailAddress"], s["ListID"].to_i, s["ClickedLinks"])}
60
+ else
61
+ raise response["Code"] + " - " + response["Message"]
62
+ end
63
+ end
64
+
65
+ # Example
66
+ # @campaign = Campaign.new(12345)
67
+ # @subscriber_unsubscribes = @campaign.unsubscribes
68
+ #
69
+ # for subscriber in @subscriber_unsubscribes
70
+ # puts subscriber.email
71
+ # end
72
+ def unsubscribes
73
+ response = @cm_client.Campaign_GetUnsubscribes("CampaignID" => @id)
74
+ return [] if response.empty?
75
+ unless response["Code"].to_i != 0
76
+ response["SubscriberUnsubscribe"].collect{|s| SubscriberUnsubscribe.new(s["EmailAddress"], s["ListID"].to_i)}
77
+ else
78
+ raise response["Code"] + " - " + response["Message"]
79
+ end
80
+ end
81
+
82
+ # Example
83
+ # @campaign = Campaign.new(12345)
84
+ # puts @campaign.number_recipients
85
+ def number_recipients
86
+ @number_recipients.nil? ? getInfo.number_recipients : @number_recipients
87
+ end
88
+
89
+ # Example
90
+ # @campaign = Campaign.new(12345)
91
+ # puts @campaign.number_opened
92
+ def number_opened
93
+ @number_opened.nil? ? getInfo.number_opened : @number_opened
94
+ end
95
+
96
+ # Example
97
+ # @campaign = Campaign.new(12345)
98
+ # puts @campaign.number_clicks
99
+ def number_clicks
100
+ @number_clicks.nil? ? getInfo.number_clicks : @number_clicks
101
+ end
102
+
103
+ # Example
104
+ # @campaign = Campaign.new(12345)
105
+ # puts @campaign.number_unsubscribed
106
+ def number_unsubscribed
107
+ @number_unsubscribed.nil? ? getInfo.number_unsubscribed : @number_unsubscribed
108
+ end
109
+
110
+ # Example
111
+ # @campaign = Campaign.new(12345)
112
+ # puts @campaign.number_bounced
113
+ def number_bounced
114
+ @number_bounced.nil? ? getInfo.number_bounced : @number_bounced
115
+ end
116
+
117
+ private
118
+ def getInfo
119
+ info = @cm_client.Campaign_GetSummary('CampaignID'=>@id)
120
+ @title = info['title']
121
+ @number_recipients = info["Recipients"].to_i
122
+ @number_opened = info["TotalOpened"].to_i
123
+ @number_clicks = info["Click"].to_i
124
+ @number_unsubscribed = info["Unsubscribed"].to_i
125
+ @number_bounced = info["Bounced"].to_i
126
+ self
127
+ end
128
+ end
129
+ end
@@ -0,0 +1,47 @@
1
+ class CampaignMonitor
2
+ # Provides access to the lists and campaigns associated with a client
3
+ class Client
4
+ attr_reader :id, :name, :cm_client
5
+
6
+ # Example
7
+ # @client = new Client(12345)
8
+ def initialize(id, name=nil)
9
+ @id = id
10
+ @name = name
11
+ @cm_client = CampaignMonitor.new
12
+ end
13
+
14
+ # Example
15
+ # @client = new Client(12345)
16
+ # @lists = @client.lists
17
+ #
18
+ # for list in @lists
19
+ # puts list.name
20
+ # end
21
+ def lists
22
+ response = @cm_client.Client_GetLists("ClientID" => @id)
23
+ return [] if response.empty?
24
+ unless response["Code"].to_i != 0
25
+ response["List"].collect{|l| List.new(l["ListID"].to_i, l["Name"])}
26
+ else
27
+ raise response["Code"] + " - " + response["Message"]
28
+ end
29
+ end
30
+
31
+ # Example
32
+ # @client = new Client(12345)
33
+ # @campaigns = @client.campaigns
34
+ #
35
+ # for campaign in @campaigns
36
+ # puts campaign.subject
37
+ # end
38
+ def campaigns
39
+ response = @cm_client.Client_GetCampaigns("ClientID" => @id)
40
+ unless response["Code"].to_i != 0
41
+ response["Campaign"].collect{|c| Campaign.new(c["CampaignID"].to_i, c["Subject"], c["SentDate"], c["TotalRecipients"].to_i)}
42
+ else
43
+ raise response["Code"] + " - " + response["Message"]
44
+ end
45
+ end
46
+ end
47
+ end
@@ -0,0 +1,92 @@
1
+ class CampaignMonitor
2
+ # Provides access to the subscribers and info about subscribers
3
+ # associated with a Mailing List
4
+ class List
5
+ attr_reader :id, :name, :cm_client
6
+
7
+ # Example
8
+ # @list = new List(12345)
9
+ def initialize(id=nil, name=nil)
10
+ @id = id
11
+ @name = name
12
+ @cm_client = CampaignMonitor.new
13
+ end
14
+
15
+ # Example
16
+ # @list = new List(12345)
17
+ # result = @list.add_subscriber("ralph.wiggum@simpsons.net")
18
+ #
19
+ # if result.succeeded?
20
+ # puts "Added Subscriber"
21
+ # end
22
+ def add_subscriber(email, name = nil)
23
+ Result.new(@cm_client.Subscriber_Add("ListID" => @id, "Email" => email, "Name" => name))
24
+ end
25
+
26
+ # Example
27
+ # @list = new List(12345)
28
+ # result = @list.remove_subscriber("ralph.wiggum@simpsons.net")
29
+ #
30
+ # if result.succeeded?
31
+ # puts "Deleted Subscriber"
32
+ # end
33
+ def remove_subscriber(email)
34
+ Result.new(@cm_client.Subscriber_Unsubscribe("ListID" => @id, "Email" => email))
35
+ end
36
+
37
+ # Example
38
+ # current_date = DateTime.new
39
+ # @list = new List(12345)
40
+ # @subscribers = @list.active_subscribers(current_date)
41
+ #
42
+ # for subscriber in @subscribers
43
+ # puts subscriber.email
44
+ # end
45
+ def active_subscribers(date)
46
+ response = @cm_client.Subscribers_GetActive('ListID' => @id, "Date" => date.strftime("%Y-%m-%d %H:%M:%S"))
47
+ return [] if response.empty?
48
+ unless response["Code"].to_i != 0
49
+ response["Subscriber"].collect{|s| Subscriber.new(s["EmailAddress"], s["Name"], s["Date"])}
50
+ else
51
+ raise response["Code"] + " - " + response["Message"]
52
+ end
53
+ end
54
+
55
+ # Example
56
+ # current_date = DateTime.new
57
+ # @list = new List(12345)
58
+ # @subscribers = @list.unsubscribed(current_date)
59
+ #
60
+ # for subscriber in @subscribers
61
+ # puts subscriber.email
62
+ # end
63
+ def unsubscribed(date)
64
+ response = @cm_client.Subscribers_GetUnsubscribed('ListID' => @id, 'Date' => date.strftime("%Y-%m-%d %H:%M:%S"))
65
+ return [] if response.empty?
66
+ unless response["Code"].to_i != 0
67
+ response["Subscriber"].collect{|s| Subscriber.new(s["EmailAddress"], s["Name"], s["Date"])}
68
+ else
69
+ raise response["Code"] + " - " + response["Message"]
70
+ end
71
+ end
72
+
73
+ # Example
74
+ # current_date = DateTime.new
75
+ # @list = new List(12345)
76
+ # @subscribers = @list.bounced(current_date)
77
+ #
78
+ # for subscriber in @subscribers
79
+ # puts subscriber.email
80
+ # end
81
+ def bounced(date)
82
+ response = @cm_client.Subscribers_GetBounced('ListID' => @id, 'Date' => date.strftime("%Y-%m-%d %H:%M:%S"))
83
+ return [] if response.empty?
84
+ unless response["Code"].to_i != 0
85
+ response["Subscriber"].collect{|s| Subscriber.new(s["EmailAddress"], s["Name"], s["Date"])}
86
+ else
87
+ raise response["Code"] + " - " + response["Message"]
88
+ end
89
+ end
90
+
91
+ end
92
+ end
@@ -0,0 +1,19 @@
1
+ class CampaignMonitor
2
+ # Encapsulates the response received from the CampaignMonitor webservice.
3
+ class Result
4
+ attr_reader :message, :code
5
+
6
+ def initialize(response)
7
+ @message = response["Message"]
8
+ @code = response["Code"].to_i
9
+ end
10
+
11
+ def succeeded?
12
+ code == 0
13
+ end
14
+
15
+ def failed?
16
+ !succeeded?
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,41 @@
1
+ class CampaignMonitor
2
+ # Provides the ability to add/remove subscribers from a list
3
+ class Subscriber
4
+ attr_accessor :email_address, :name, :date_subscribed
5
+
6
+ def initialize(email_address, name=nil, date=nil)
7
+ @email_address = email_address
8
+ @name = name
9
+ @date_subscribed = date_subscribed
10
+ @cm_client = CampaignMonitor.new
11
+ end
12
+
13
+ # Example
14
+ # @subscriber = Subscriber.new("ralph.wiggum@simpsons.net")
15
+ # @subscriber.add(12345)
16
+ def add(list_id)
17
+ Result.new(@cm_client.Subscriber_Add("ListID" => list_id, "Email" => @email_address, "Name" => @name))
18
+ end
19
+
20
+ # Example
21
+ # @subscriber = Subscriber.new("ralph.wiggum@simpsons.net")
22
+ # @subscriber.add_and_resubscribe(12345)
23
+ def add_and_resubscribe(list_id)
24
+ Result.new(@cm_client.Subscriber_AddAndResubscribe("ListID" => list_id, "Email" => @email_address, "Name" => @name))
25
+ end
26
+
27
+ # Example
28
+ # @subscriber = Subscriber.new("ralph.wiggum@simpsons.net")
29
+ # @subscriber.unsubscribe(12345)
30
+ def unsubscribe(list_id)
31
+ Result.new(@cm_client.Subscriber_Unsubscribe("ListID" => list_id, "Email" => @email_address))
32
+ end
33
+
34
+ def is_subscribed?(list_id)
35
+ result = @cm_client.Subscribers_GetIsSubscribed("ListID" => list_id, "Email" => @email_address)
36
+ return true if result == 'True'
37
+ return false if result == 'False'
38
+ raise "Invalid value for is_subscribed?: #{result}"
39
+ end
40
+ end
41
+ end
@@ -0,0 +1,6 @@
1
+ class CampaignMonitorTest < Test::Unit::TestCase
2
+
3
+ def setup
4
+
5
+ end
6
+ end
metadata ADDED
@@ -0,0 +1,82 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: Empact-campaign_monitor
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.1
5
+ platform: ruby
6
+ authors:
7
+ - Jordan Brock
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+
12
+ date: 2008-08-13 00:00:00 -07:00
13
+ default_executable:
14
+ dependencies: []
15
+
16
+ description: A simple wrapper class that provides basic access to the Campaign Monitor API
17
+ email: jordan@spintech.com.au
18
+ executables: []
19
+
20
+ extensions: []
21
+
22
+ extra_rdoc_files:
23
+ - LICENSE
24
+ - CHANGELOG
25
+ - TODO
26
+ - lib/campaign_monitor.rb
27
+ - lib/campaign_monitor/campaign.rb
28
+ - lib/campaign_monitor/list.rb
29
+ - lib/campaign_monitor/client.rb
30
+ - lib/campaign_monitor/result.rb
31
+ - lib/campaign_monitor/subscriber.rb
32
+ - README.rdoc
33
+ files:
34
+ - LICENSE
35
+ - CHANGELOG
36
+ - init.rb
37
+ - Rakefile
38
+ - test/campaign_monitor_test.rb
39
+ - TODO
40
+ - lib/campaign_monitor.rb
41
+ - lib/campaign_monitor/campaign.rb
42
+ - lib/campaign_monitor/list.rb
43
+ - lib/campaign_monitor/client.rb
44
+ - lib/campaign_monitor/result.rb
45
+ - lib/campaign_monitor/subscriber.rb
46
+ - README.rdoc
47
+ - install.rb
48
+ - campaign-monitor-ruby.gemspec
49
+ - Manifest
50
+ has_rdoc: true
51
+ homepage: http://spintech.com.au/projects/plugins/campaign_monitor
52
+ post_install_message:
53
+ rdoc_options:
54
+ - --line-numbers
55
+ - --inline-source
56
+ - --title
57
+ - Campaign-monitor-ruby
58
+ - --main
59
+ - README.rdoc
60
+ require_paths:
61
+ - lib
62
+ required_ruby_version: !ruby/object:Gem::Requirement
63
+ requirements:
64
+ - - ">="
65
+ - !ruby/object:Gem::Version
66
+ version: "0"
67
+ version:
68
+ required_rubygems_version: !ruby/object:Gem::Requirement
69
+ requirements:
70
+ - - ">="
71
+ - !ruby/object:Gem::Version
72
+ version: "0"
73
+ version:
74
+ requirements:
75
+ - none
76
+ rubyforge_project: campaignmonitor
77
+ rubygems_version: 1.2.0
78
+ signing_key:
79
+ specification_version: 2
80
+ summary: Provides access to the Campaign Monitor API
81
+ test_files:
82
+ - test/campaign_monitor_test.rb