madmimi-bernardo 1.0.14
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +3 -0
- data/LICENSE +20 -0
- data/README.rdoc +98 -0
- data/Rakefile +56 -0
- data/VERSION +1 -0
- data/lib/madmimi.rb +247 -0
- data/madmimi.gemspec +65 -0
- data/test/fixtures/lists.xml +7 -0
- data/test/fixtures/promotions.xml +10 -0
- data/test/fixtures/search.xml +38 -0
- data/test/helper.rb +38 -0
- data/test/test_madmimi.rb +27 -0
- metadata +144 -0
data/.gitignore
ADDED
data/LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (c) 2010 Nicholas Young <nicholas@madmimi.com>
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.rdoc
ADDED
@@ -0,0 +1,98 @@
|
|
1
|
+
= madmimi
|
2
|
+
|
3
|
+
The power of Mad Mimi in your Ruby application. Deliver emails, track statistics, and manage your subscriber base with ease.
|
4
|
+
|
5
|
+
== Installation
|
6
|
+
|
7
|
+
gem install madmimi - or if you prefer to live on the edge, just clone this repository and build it from scratch.
|
8
|
+
|
9
|
+
== Basic Usage
|
10
|
+
|
11
|
+
Dependencies:
|
12
|
+
active_support (I intend to remove this in the not too distant future, and build my own implementation.)
|
13
|
+
|
14
|
+
mimi = MadMimi.new('emailaddress', 'api_key')
|
15
|
+
|
16
|
+
mimi.lists -> get all of your Mad Mimi lists returned as a hash
|
17
|
+
|
18
|
+
mimi.memberships('email') -> returns a hash of the lists that specific email address is subscribed to
|
19
|
+
|
20
|
+
mimi.new_list('New list name') -> make a new list
|
21
|
+
|
22
|
+
mimi.delete_list('New list name') -> delete the list I just created
|
23
|
+
|
24
|
+
mimi.csv_import("name,email\ndave,dave@example.com\n") -> import from a csv string
|
25
|
+
|
26
|
+
mimi.add_to_list('dave@example.com', 'Test List') -> add this email address to a specific list
|
27
|
+
|
28
|
+
mimi.remove_from_list('dave@example.com', 'Test List') -> remove this email address from a specific list
|
29
|
+
|
30
|
+
mimi.suppressed_since('unix timestamp') -> get a TXT of all addresses that were suppressed since this timestamp
|
31
|
+
|
32
|
+
mimi.promotions -> returns a hash of your promotions
|
33
|
+
|
34
|
+
mimi.mailing_stats('promotion_id', 'mailing_id') -> get stats on a specific mailing
|
35
|
+
|
36
|
+
== Sending E-Mail (using the Mailer API)
|
37
|
+
|
38
|
+
=== Replacing keys in your email body text:
|
39
|
+
|
40
|
+
options = { 'promotion_name' => 'Test Promotion', 'recipients' => 'Nicholas Young <nicholas@madmimi.com>', 'from' => 'MadMimi Ruby <rubygem@madmimi.com>', 'subject' => 'Test Subject' }
|
41
|
+
|
42
|
+
yaml_body = { 'greeting' => 'Hello', 'name' => 'Nicholas' }
|
43
|
+
|
44
|
+
mimi.send_mail(options, yaml_body)
|
45
|
+
|
46
|
+
=== Sending Raw HTML (presumably generated by your app)
|
47
|
+
|
48
|
+
options = { 'promotion_name' => 'Test Promotion', 'recipients' => 'Nicholas Young <nicholas@madmimi.com>', 'from' => 'MadMimi Ruby <rubygem@madmimi.com>', 'subject' => 'Test Subject' }
|
49
|
+
|
50
|
+
raw_html = "<html><head><title>My great promotion!</title></head><body>Body stuff[[tracking_beacon]]</body></html>"
|
51
|
+
|
52
|
+
mimi.send_html(options, raw_html)
|
53
|
+
|
54
|
+
=== Sending Plain Text
|
55
|
+
|
56
|
+
options = { 'promotion_name' => 'Test Promotion', 'recipients' => 'Nicholas Young <nicholas@madmimi.com>', 'from' => 'MadMimi Ruby <rubygem@madmimi.com>', 'subject' => 'Test Subject' }
|
57
|
+
|
58
|
+
plain_text = "Plain text email contents [[unsubscribe]]"
|
59
|
+
|
60
|
+
mimi.send_plaintext(options, plain_text)
|
61
|
+
|
62
|
+
=== Return values
|
63
|
+
|
64
|
+
In most cases, a return value of a single space indicates success.
|
65
|
+
|
66
|
+
On success, #send_mail, #send_html, and #send_plaintext return String with a numeric mailing_id. This mailing_id can be used to look up stats with #mailing_stats.
|
67
|
+
|
68
|
+
Errors or issues preventing operation completing return a human-readable String.
|
69
|
+
|
70
|
+
Therefore, if the return value is not a space, or is not a numeric String value, then
|
71
|
+
there is probably an error or uncompleted operation.
|
72
|
+
|
73
|
+
=== Specific options keys
|
74
|
+
|
75
|
+
'raw_html': Must include at least one of the [[tracking_beacon]] or [[peek_image]] tags.
|
76
|
+
|
77
|
+
'promotion_name': If a promotion doesn't exist under the given name, it will be created.
|
78
|
+
If it exists and you specify raw_html, the promotion body will be replaced.
|
79
|
+
|
80
|
+
'list_name': For all of the #send methods, if 'list_name' is provided, the recipients
|
81
|
+
will be those for an already-existing "audience."
|
82
|
+
|
83
|
+
== Note on Patches/Pull Requests
|
84
|
+
|
85
|
+
* Fork the project.
|
86
|
+
* Make your feature addition or bug fix.
|
87
|
+
* Add tests for it. This is important so I don't break it in a
|
88
|
+
future version unintentionally.
|
89
|
+
* Commit, do not mess with rakefile, version, or history.
|
90
|
+
(if you want to have your own version, that is fine but bump version in a commit by itself I can ignore when I pull)
|
91
|
+
* Send me a pull request. Bonus points for topic branches.
|
92
|
+
|
93
|
+
== Contributors
|
94
|
+
tuker
|
95
|
+
|
96
|
+
== Copyright
|
97
|
+
|
98
|
+
Copyright (c) 2010 Nicholas Young. See LICENSE for details.
|
data/Rakefile
ADDED
@@ -0,0 +1,56 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'rake'
|
3
|
+
|
4
|
+
begin
|
5
|
+
require 'jeweler'
|
6
|
+
Jeweler::Tasks.new do |gem|
|
7
|
+
gem.name = "madmimi-bernardo"
|
8
|
+
gem.summary = %Q{Mad Mimi API wrapper for Ruby}
|
9
|
+
gem.description = %Q{Send emails, track statistics, and manage your subscriber base with ease.}
|
10
|
+
gem.email = "nicholas@madmimi.com"
|
11
|
+
gem.homepage = "http://github.com/madmimi/madmimi-gem"
|
12
|
+
gem.authors = ["Nicholas Young", "Marc Heiligers"]
|
13
|
+
gem.add_dependency "crack", "0.1.7"
|
14
|
+
gem.add_development_dependency "jeweler", "1.4.0"
|
15
|
+
gem.add_development_dependency "fakeweb", "1.2.8"
|
16
|
+
gem.add_development_dependency "shoulda", "2.10.3"
|
17
|
+
# gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings
|
18
|
+
end
|
19
|
+
Jeweler::GemcutterTasks.new
|
20
|
+
rescue LoadError
|
21
|
+
puts "Jeweler (or a dependency) not available. Install it with: gem install jeweler"
|
22
|
+
end
|
23
|
+
|
24
|
+
require 'rake/testtask'
|
25
|
+
Rake::TestTask.new(:test) do |test|
|
26
|
+
test.libs << 'lib' << 'test'
|
27
|
+
test.pattern = 'test/**/test_*.rb'
|
28
|
+
test.verbose = true
|
29
|
+
end
|
30
|
+
|
31
|
+
begin
|
32
|
+
require 'rcov/rcovtask'
|
33
|
+
Rcov::RcovTask.new do |test|
|
34
|
+
test.libs << 'test'
|
35
|
+
test.pattern = 'test/**/test_*.rb'
|
36
|
+
test.verbose = true
|
37
|
+
end
|
38
|
+
rescue LoadError
|
39
|
+
task :rcov do
|
40
|
+
abort "RCov is not available. In order to run rcov, you must: sudo gem install spicycode-rcov"
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
task :test => :check_dependencies
|
45
|
+
|
46
|
+
task :default => :test
|
47
|
+
|
48
|
+
require 'rake/rdoctask'
|
49
|
+
Rake::RDocTask.new do |rdoc|
|
50
|
+
version = File.exist?('VERSION') ? File.read('VERSION') : ""
|
51
|
+
|
52
|
+
rdoc.rdoc_dir = 'rdoc'
|
53
|
+
rdoc.title = "madmimi #{version}"
|
54
|
+
rdoc.rdoc_files.include('README*')
|
55
|
+
rdoc.rdoc_files.include('lib/**/*.rb')
|
56
|
+
end
|
data/VERSION
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
1.0.14
|
data/lib/madmimi.rb
ADDED
@@ -0,0 +1,247 @@
|
|
1
|
+
# Mad Mimi for Ruby
|
2
|
+
|
3
|
+
# License
|
4
|
+
|
5
|
+
# Copyright (c) 2010 Mad Mimi (nicholas@madmimi.com)
|
6
|
+
|
7
|
+
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
8
|
+
# of this software and associated documentation files (the "Software"), to deal
|
9
|
+
# in the Software without restriction, including without limitation the rights
|
10
|
+
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
11
|
+
# copies of the Software, and to permit persons to whom the Software is
|
12
|
+
# furnished to do so, subject to the following conditions:
|
13
|
+
|
14
|
+
# The above copyright notice and this permission notice shall be included in
|
15
|
+
# all copies or substantial portions of the Software.
|
16
|
+
|
17
|
+
# Except as contained in this notice, the name(s) of the above copyright holder(s)
|
18
|
+
# shall not be used in advertising or otherwise to promote the sale, use or other
|
19
|
+
# dealings in this Software without prior written authorization.
|
20
|
+
|
21
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
22
|
+
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
23
|
+
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
24
|
+
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
25
|
+
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
26
|
+
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
27
|
+
# THE SOFTWARE.
|
28
|
+
|
29
|
+
require 'uri'
|
30
|
+
require 'net/http'
|
31
|
+
require 'net/https'
|
32
|
+
require 'crack'
|
33
|
+
require 'csv'
|
34
|
+
|
35
|
+
class MadMimi
|
36
|
+
|
37
|
+
class MadMimiError < StandardError; end
|
38
|
+
|
39
|
+
BASE_URL = 'api.madmimi.com'
|
40
|
+
NEW_LISTS_PATH = '/audience_lists'
|
41
|
+
AUDIENCE_MEMBERS_PATH = '/audience_members'
|
42
|
+
AUDIENCE_LISTS_PATH = '/audience_lists/lists.xml'
|
43
|
+
MEMBERSHIPS_PATH = '/audience_members/%email%/lists.xml'
|
44
|
+
SUPPRESSED_SINCE_PATH = '/audience_members/suppressed_since/%timestamp%.txt'
|
45
|
+
SUPPRESS_USER_PATH = ' /audience_members/%email%/suppress_email'
|
46
|
+
IS_SUPPRESSED_PATH = '/audience_members/%email%/is_suppressed'
|
47
|
+
PROMOTIONS_PATH = '/promotions.xml'
|
48
|
+
MAILING_STATS_PATH = '/promotions/%promotion_id%/mailings/%mailing_id%.xml'
|
49
|
+
SEARCH_PATH = '/audience_members/search.xml'
|
50
|
+
MAILER_PATH = '/mailer'
|
51
|
+
TRANSACTIONAL_MAILING_STATUS_PATH = '/mailers/status/%transaction_id%'
|
52
|
+
MAILER_TO_LIST_PATH = '/mailer/to_list'
|
53
|
+
|
54
|
+
def initialize(username, api_key)
|
55
|
+
@api_settings = { :username => username, :api_key => api_key }
|
56
|
+
end
|
57
|
+
|
58
|
+
def username
|
59
|
+
@api_settings[:username]
|
60
|
+
end
|
61
|
+
|
62
|
+
def api_key
|
63
|
+
@api_settings[:api_key]
|
64
|
+
end
|
65
|
+
|
66
|
+
def default_opt
|
67
|
+
{ :username => username, :api_key => api_key }
|
68
|
+
end
|
69
|
+
|
70
|
+
def lists
|
71
|
+
request = do_request(AUDIENCE_LISTS_PATH, :get)
|
72
|
+
Crack::XML.parse(request)
|
73
|
+
end
|
74
|
+
|
75
|
+
def memberships(email)
|
76
|
+
request = do_request(MEMBERSHIPS_PATH.gsub('%email%', email), :get)
|
77
|
+
Crack::XML.parse(request)
|
78
|
+
end
|
79
|
+
|
80
|
+
def new_list(list_name)
|
81
|
+
do_request(NEW_LISTS_PATH, :post, :name => list_name)
|
82
|
+
end
|
83
|
+
|
84
|
+
def delete_list(list_name)
|
85
|
+
do_request("#{NEW_LISTS_PATH}/#{URI.escape(list_name)}", :post, :'_method' => 'delete')
|
86
|
+
end
|
87
|
+
|
88
|
+
def csv_import(csv_string)
|
89
|
+
do_request(AUDIENCE_MEMBERS_PATH, :post, :csv_file => csv_string)
|
90
|
+
end
|
91
|
+
|
92
|
+
def add_user(options)
|
93
|
+
csv_data = build_csv(options)
|
94
|
+
do_request(AUDIENCE_MEMBERS_PATH, :post, :csv_file => csv_data)
|
95
|
+
end
|
96
|
+
|
97
|
+
def add_to_list(email, list_name)
|
98
|
+
do_request("#{NEW_LISTS_PATH}/#{URI.escape(list_name)}/add", :post, :email => email)
|
99
|
+
end
|
100
|
+
|
101
|
+
def remove_from_list(email, list_name)
|
102
|
+
do_request("#{NEW_LISTS_PATH}/#{URI.escape(list_name)}/remove", :post, :email => email)
|
103
|
+
end
|
104
|
+
|
105
|
+
def suppressed_since(timestamp)
|
106
|
+
do_request(SUPPRESSED_SINCE_PATH.gsub('%timestamp%', timestamp), :get)
|
107
|
+
end
|
108
|
+
|
109
|
+
def suppress_email(email)
|
110
|
+
do_request(SUPPRESS_USER_PATH.gsub('%email%', email), :post)
|
111
|
+
end
|
112
|
+
|
113
|
+
def is_suppressed(email)
|
114
|
+
response = do_request(IS_SUPPRESSED_PATH.gsub('%email%', email), :get)
|
115
|
+
case response
|
116
|
+
when 'true'
|
117
|
+
true
|
118
|
+
when 'false', /does not exist/
|
119
|
+
false
|
120
|
+
end
|
121
|
+
end
|
122
|
+
|
123
|
+
def promotions
|
124
|
+
request = do_request(PROMOTIONS_PATH, :get)
|
125
|
+
Crack::XML.parse(request)
|
126
|
+
end
|
127
|
+
|
128
|
+
def mailing_stats(promotion_id, mailing_id)
|
129
|
+
path = MAILING_STATS_PATH.gsub('%promotion_id%', promotion_id).gsub('%mailing_id%', mailing_id)
|
130
|
+
request = do_request(path, :get)
|
131
|
+
Crack::XML.parse(request)
|
132
|
+
end
|
133
|
+
|
134
|
+
def audience_search(query_string, raw = false)
|
135
|
+
request = do_request(SEARCH_PATH, :get, :raw => raw, :query => query_string)
|
136
|
+
Crack::XML.parse(request)
|
137
|
+
end
|
138
|
+
|
139
|
+
def send_mail(opt, yaml_body)
|
140
|
+
options = opt.dup
|
141
|
+
options[:body] = yaml_body.to_yaml
|
142
|
+
if !options[:list_name].nil?
|
143
|
+
do_request(MAILER_TO_LIST_PATH, :post, options, true)
|
144
|
+
else
|
145
|
+
do_request(MAILER_PATH, :post, options, true)
|
146
|
+
end
|
147
|
+
end
|
148
|
+
|
149
|
+
def transactional_mailing_status(transaction_id)
|
150
|
+
do_request(TRANSACTIONAL_MAILING_STATUS_PATH.gsub('%transaction_id%', transaction_id.to_s), :get)
|
151
|
+
end
|
152
|
+
|
153
|
+
# Not the most elegant, but it works for now. :)
|
154
|
+
def add_users_to_list(list_name, arr)
|
155
|
+
arr.each do |a|
|
156
|
+
a[:add_list] = list_name
|
157
|
+
add_user(a)
|
158
|
+
end
|
159
|
+
end
|
160
|
+
|
161
|
+
def send_html(opt, html)
|
162
|
+
options = opt.dup
|
163
|
+
if html.include?('[[tracking_beacon]]') || html.include?('[[peek_image]]')
|
164
|
+
options[:raw_html] = html
|
165
|
+
if !options[:list_name].nil?
|
166
|
+
unless html.include?('[[unsubscribe]]') || html.include?('[[opt_out]]')
|
167
|
+
raise MadMimiError, "When specifying list_name, include the [[unsubscribe]] or [[opt_out]] macro in your HTML before sending."
|
168
|
+
end
|
169
|
+
do_request(MAILER_TO_LIST_PATH, :post, options, true)
|
170
|
+
else
|
171
|
+
do_request(MAILER_PATH, :post, options, true)
|
172
|
+
end
|
173
|
+
else
|
174
|
+
raise MadMimiError, "You'll need to include either the [[tracking_beacon]] or [[peek_image]] macro in your HTML before sending."
|
175
|
+
end
|
176
|
+
end
|
177
|
+
|
178
|
+
def send_plaintext(opt, plaintext)
|
179
|
+
options = opt.dup
|
180
|
+
options[:raw_plain_text] = plaintext
|
181
|
+
if !options[:list_name].nil?
|
182
|
+
if plaintext.include?('[[unsubscribe]]') || plaintext.include?('[[opt_out]]')
|
183
|
+
do_request(MAILER_TO_LIST_PATH, :post, options, true)
|
184
|
+
else
|
185
|
+
raise MadMimiError, "You'll need to include either the [[unsubscribe]] or [[opt_out]] macro in your text before sending."
|
186
|
+
end
|
187
|
+
else
|
188
|
+
do_request(MAILER_PATH, :post, options, true)
|
189
|
+
end
|
190
|
+
end
|
191
|
+
|
192
|
+
private
|
193
|
+
|
194
|
+
# Refactor this method asap
|
195
|
+
def do_request(path, req_type = :get, options = {}, transactional = false)
|
196
|
+
options = options.merge(default_opt)
|
197
|
+
form_data = options.inject({}) { |m, (k, v)| m[k.to_s] = v; m }
|
198
|
+
resp = href = ""
|
199
|
+
case req_type
|
200
|
+
when :get then
|
201
|
+
begin
|
202
|
+
http = Net::HTTP.new(BASE_URL, 80)
|
203
|
+
http.start do |http|
|
204
|
+
req = Net::HTTP::Get.new(path)
|
205
|
+
req.set_form_data(form_data)
|
206
|
+
response = http.request(req)
|
207
|
+
resp = response.body.strip
|
208
|
+
end
|
209
|
+
resp
|
210
|
+
rescue SocketError
|
211
|
+
raise "Host unreachable."
|
212
|
+
end
|
213
|
+
when :post then
|
214
|
+
begin
|
215
|
+
if transactional == true
|
216
|
+
http = Net::HTTP.new(BASE_URL, 443)
|
217
|
+
http.use_ssl = true
|
218
|
+
http.verify_mode = OpenSSL::SSL::VERIFY_NONE
|
219
|
+
else
|
220
|
+
http = Net::HTTP.new(BASE_URL, 80)
|
221
|
+
end
|
222
|
+
http.start do |http|
|
223
|
+
req = Net::HTTP::Post.new(path)
|
224
|
+
req.set_form_data(form_data)
|
225
|
+
response = http.request(req)
|
226
|
+
resp = response.body.strip
|
227
|
+
end
|
228
|
+
rescue SocketError
|
229
|
+
raise "Host unreachable."
|
230
|
+
end
|
231
|
+
end
|
232
|
+
end
|
233
|
+
|
234
|
+
def build_csv(hash)
|
235
|
+
if CSV.respond_to?(:generate_row) # before Ruby 1.9
|
236
|
+
buffer = ''
|
237
|
+
CSV.generate_row(hash.keys, hash.keys.size, buffer)
|
238
|
+
CSV.generate_row(hash.values, hash.values.size, buffer)
|
239
|
+
buffer
|
240
|
+
else # Ruby 1.9 and after
|
241
|
+
CSV.generate do |csv|
|
242
|
+
csv << hash.keys
|
243
|
+
csv << hash.values
|
244
|
+
end
|
245
|
+
end
|
246
|
+
end
|
247
|
+
end
|
data/madmimi.gemspec
ADDED
@@ -0,0 +1,65 @@
|
|
1
|
+
# Generated by jeweler
|
2
|
+
# DO NOT EDIT THIS FILE DIRECTLY
|
3
|
+
# Instead, edit Jeweler::Tasks in Rakefile, and run the gemspec command
|
4
|
+
# -*- encoding: utf-8 -*-
|
5
|
+
|
6
|
+
Gem::Specification.new do |s|
|
7
|
+
s.name = %q{madmimi}
|
8
|
+
s.version = "1.0.14"
|
9
|
+
|
10
|
+
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
|
+
s.authors = ["Nicholas Young", "Marc Heiligers"]
|
12
|
+
s.date = %q{2010-10-06}
|
13
|
+
s.description = %q{Send emails, track statistics, and manage your subscriber base with ease.}
|
14
|
+
s.email = %q{nicholas@madmimi.com}
|
15
|
+
s.extra_rdoc_files = [
|
16
|
+
"LICENSE",
|
17
|
+
"README.rdoc"
|
18
|
+
]
|
19
|
+
s.files = [
|
20
|
+
".gitignore",
|
21
|
+
"LICENSE",
|
22
|
+
"README.rdoc",
|
23
|
+
"Rakefile",
|
24
|
+
"VERSION",
|
25
|
+
"lib/madmimi.rb",
|
26
|
+
"madmimi.gemspec",
|
27
|
+
"test/fixtures/lists.xml",
|
28
|
+
"test/fixtures/promotions.xml",
|
29
|
+
"test/fixtures/search.xml",
|
30
|
+
"test/helper.rb",
|
31
|
+
"test/test_madmimi.rb"
|
32
|
+
]
|
33
|
+
s.homepage = %q{http://github.com/madmimi/madmimi-gem}
|
34
|
+
s.rdoc_options = ["--charset=UTF-8"]
|
35
|
+
s.require_paths = ["lib"]
|
36
|
+
s.rubygems_version = %q{1.3.7}
|
37
|
+
s.summary = %q{Mad Mimi API wrapper for Ruby}
|
38
|
+
s.test_files = [
|
39
|
+
"test/helper.rb",
|
40
|
+
"test/test_madmimi.rb"
|
41
|
+
]
|
42
|
+
|
43
|
+
if s.respond_to? :specification_version then
|
44
|
+
current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
|
45
|
+
s.specification_version = 3
|
46
|
+
|
47
|
+
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
48
|
+
s.add_runtime_dependency(%q<crack>, ["= 0.1.7"])
|
49
|
+
s.add_development_dependency(%q<jeweler>, ["= 1.4.0"])
|
50
|
+
s.add_development_dependency(%q<fakeweb>, ["= 1.2.8"])
|
51
|
+
s.add_development_dependency(%q<shoulda>, ["= 2.10.3"])
|
52
|
+
else
|
53
|
+
s.add_dependency(%q<crack>, ["= 0.1.7"])
|
54
|
+
s.add_dependency(%q<jeweler>, ["= 1.4.0"])
|
55
|
+
s.add_dependency(%q<fakeweb>, ["= 1.2.8"])
|
56
|
+
s.add_dependency(%q<shoulda>, ["= 2.10.3"])
|
57
|
+
end
|
58
|
+
else
|
59
|
+
s.add_dependency(%q<crack>, ["= 0.1.7"])
|
60
|
+
s.add_dependency(%q<jeweler>, ["= 1.4.0"])
|
61
|
+
s.add_dependency(%q<fakeweb>, ["= 1.2.8"])
|
62
|
+
s.add_dependency(%q<shoulda>, ["= 2.10.3"])
|
63
|
+
end
|
64
|
+
end
|
65
|
+
|
@@ -0,0 +1,7 @@
|
|
1
|
+
<lists>
|
2
|
+
<list subscriber_count="0" name="Funky List" id="90920"/>
|
3
|
+
<list subscriber_count="0" name="New Test" id="90913"/>
|
4
|
+
<list subscriber_count="0" name="New Test List" id="93852"/>
|
5
|
+
<list subscriber_count="0" name="Other test" id="89621"/>
|
6
|
+
<list subscriber_count="0" name="Test List" id="88803"/>
|
7
|
+
</lists>
|
@@ -0,0 +1,10 @@
|
|
1
|
+
<promotions>
|
2
|
+
<promotion updated_at="Mon May 24 19:58:02 -0400 2010" mimio="1bee3" name="HTML Test" id="257713">
|
3
|
+
</promotion>
|
4
|
+
<promotion updated_at="Mon May 24 13:20:14 -0400 2010" mimio="69ce3" name="Untitled Promotion" id="257174">
|
5
|
+
<mailing id="1274713">
|
6
|
+
<started_send>Mon May 24 13:20:03 -0400 2010</started_send>
|
7
|
+
<finished_send>Mon May 24 13:20:06 -0400 2010</finished_send>
|
8
|
+
</mailing>
|
9
|
+
</promotion>
|
10
|
+
</promotions>
|
@@ -0,0 +1,38 @@
|
|
1
|
+
<audience>
|
2
|
+
<member suppressed="false">
|
3
|
+
<first_name></first_name>
|
4
|
+
<last_name></last_name>
|
5
|
+
<email>nicholas@madmimi.com</email>
|
6
|
+
<created_at>Mon May 24 13:19:59 -0400 2010</created_at>
|
7
|
+
<city></city>
|
8
|
+
<phone></phone>
|
9
|
+
<company></company>
|
10
|
+
<title></title>
|
11
|
+
<address></address>
|
12
|
+
<state></state>
|
13
|
+
<zip></zip>
|
14
|
+
<country></country>
|
15
|
+
<confirmed></confirmed>
|
16
|
+
<music></music>
|
17
|
+
<lists>
|
18
|
+
</lists>
|
19
|
+
</member>
|
20
|
+
<member suppressed="false">
|
21
|
+
<first_name></first_name>
|
22
|
+
<last_name></last_name>
|
23
|
+
<email>nicholas@nicholaswyoung.com</email>
|
24
|
+
<created_at>Mon May 24 20:17:30 -0400 2010</created_at>
|
25
|
+
<city></city>
|
26
|
+
<phone></phone>
|
27
|
+
<company></company>
|
28
|
+
<title></title>
|
29
|
+
<address></address>
|
30
|
+
<state></state>
|
31
|
+
<zip></zip>
|
32
|
+
<country></country>
|
33
|
+
<confirmed></confirmed>
|
34
|
+
<music></music>
|
35
|
+
<lists>
|
36
|
+
</lists>
|
37
|
+
</member>
|
38
|
+
</audience>
|
data/test/helper.rb
ADDED
@@ -0,0 +1,38 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'test/unit'
|
3
|
+
require 'shoulda'
|
4
|
+
require 'fakeweb'
|
5
|
+
|
6
|
+
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
|
7
|
+
$LOAD_PATH.unshift(File.dirname(__FILE__))
|
8
|
+
require 'madmimi'
|
9
|
+
|
10
|
+
class Test::Unit::TestCase
|
11
|
+
end
|
12
|
+
|
13
|
+
def fixture_file(filename)
|
14
|
+
return '' if filename == ''
|
15
|
+
file_path = File.expand_path(File.dirname(__FILE__) + '/fixtures/' + filename)
|
16
|
+
File.read(file_path)
|
17
|
+
end
|
18
|
+
|
19
|
+
def madmimi_url(url, https = false)
|
20
|
+
if https = false
|
21
|
+
url =~ /^http/ ? url : "http://api.madmimi.com#{url}"
|
22
|
+
else
|
23
|
+
url =~ /^https/ ? url : "https://api.madmimi.com#{url}"
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
def stub_get(url, filename, status = nil)
|
28
|
+
options = { :body => fixture_file(filename) }
|
29
|
+
options.merge!({ :status => status }) unless status.nil?
|
30
|
+
FakeWeb.register_uri(:get, madmimi_url(url), options)
|
31
|
+
end
|
32
|
+
|
33
|
+
# In the process of tweaking this. - Nicholas
|
34
|
+
def stub_post(url, filename = nil, status = nil)
|
35
|
+
options = { :body => "" }
|
36
|
+
options.merge!({ :status => status }) unless status.nil?
|
37
|
+
FakeWeb.register_url(:get, madmimi_url(url), options)
|
38
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
require 'helper'
|
2
|
+
|
3
|
+
class TestMadmimi < Test::Unit::TestCase
|
4
|
+
context "A API call" do
|
5
|
+
setup do
|
6
|
+
@mimi = MadMimi.new('email@example.com', 'testapikey')
|
7
|
+
end
|
8
|
+
|
9
|
+
should "retrieve a hash of promotions" do
|
10
|
+
stub_get('/promotions.xml', 'promotions.xml')
|
11
|
+
response = @mimi.promotions
|
12
|
+
flunk "I couldn't find any promotions." unless response.kind_of?(Hash) || !response.empty?
|
13
|
+
end
|
14
|
+
|
15
|
+
should "retrieve a hash of lists" do
|
16
|
+
stub_get('/audience_lists/lists.xml', 'lists.xml')
|
17
|
+
response = @mimi.lists
|
18
|
+
flunk "Doesn't return any lists." unless response.kind_of?(Hash) || !response.empty?
|
19
|
+
end
|
20
|
+
|
21
|
+
should "retrieve a hash of users found with the search term nicholas" do
|
22
|
+
stub_get('/audience_members/search.xml?query=nicholas', 'search.xml')
|
23
|
+
response = @mimi.audience_search('nicholas')
|
24
|
+
flunk "No users found." unless response.kind_of?(Hash) || !response.empty?
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
metadata
ADDED
@@ -0,0 +1,144 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: madmimi-bernardo
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
hash: 11
|
5
|
+
prerelease: false
|
6
|
+
segments:
|
7
|
+
- 1
|
8
|
+
- 0
|
9
|
+
- 14
|
10
|
+
version: 1.0.14
|
11
|
+
platform: ruby
|
12
|
+
authors:
|
13
|
+
- Nicholas Young
|
14
|
+
- Marc Heiligers
|
15
|
+
autorequire:
|
16
|
+
bindir: bin
|
17
|
+
cert_chain: []
|
18
|
+
|
19
|
+
date: 2010-10-06 00:00:00 -03:00
|
20
|
+
default_executable:
|
21
|
+
dependencies:
|
22
|
+
- !ruby/object:Gem::Dependency
|
23
|
+
name: crack
|
24
|
+
prerelease: false
|
25
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
26
|
+
none: false
|
27
|
+
requirements:
|
28
|
+
- - "="
|
29
|
+
- !ruby/object:Gem::Version
|
30
|
+
hash: 21
|
31
|
+
segments:
|
32
|
+
- 0
|
33
|
+
- 1
|
34
|
+
- 7
|
35
|
+
version: 0.1.7
|
36
|
+
type: :runtime
|
37
|
+
version_requirements: *id001
|
38
|
+
- !ruby/object:Gem::Dependency
|
39
|
+
name: jeweler
|
40
|
+
prerelease: false
|
41
|
+
requirement: &id002 !ruby/object:Gem::Requirement
|
42
|
+
none: false
|
43
|
+
requirements:
|
44
|
+
- - "="
|
45
|
+
- !ruby/object:Gem::Version
|
46
|
+
hash: 7
|
47
|
+
segments:
|
48
|
+
- 1
|
49
|
+
- 4
|
50
|
+
- 0
|
51
|
+
version: 1.4.0
|
52
|
+
type: :development
|
53
|
+
version_requirements: *id002
|
54
|
+
- !ruby/object:Gem::Dependency
|
55
|
+
name: fakeweb
|
56
|
+
prerelease: false
|
57
|
+
requirement: &id003 !ruby/object:Gem::Requirement
|
58
|
+
none: false
|
59
|
+
requirements:
|
60
|
+
- - "="
|
61
|
+
- !ruby/object:Gem::Version
|
62
|
+
hash: 15
|
63
|
+
segments:
|
64
|
+
- 1
|
65
|
+
- 2
|
66
|
+
- 8
|
67
|
+
version: 1.2.8
|
68
|
+
type: :development
|
69
|
+
version_requirements: *id003
|
70
|
+
- !ruby/object:Gem::Dependency
|
71
|
+
name: shoulda
|
72
|
+
prerelease: false
|
73
|
+
requirement: &id004 !ruby/object:Gem::Requirement
|
74
|
+
none: false
|
75
|
+
requirements:
|
76
|
+
- - "="
|
77
|
+
- !ruby/object:Gem::Version
|
78
|
+
hash: 33
|
79
|
+
segments:
|
80
|
+
- 2
|
81
|
+
- 10
|
82
|
+
- 3
|
83
|
+
version: 2.10.3
|
84
|
+
type: :development
|
85
|
+
version_requirements: *id004
|
86
|
+
description: Send emails, track statistics, and manage your subscriber base with ease.
|
87
|
+
email: nicholas@madmimi.com
|
88
|
+
executables: []
|
89
|
+
|
90
|
+
extensions: []
|
91
|
+
|
92
|
+
extra_rdoc_files:
|
93
|
+
- LICENSE
|
94
|
+
- README.rdoc
|
95
|
+
files:
|
96
|
+
- .gitignore
|
97
|
+
- LICENSE
|
98
|
+
- README.rdoc
|
99
|
+
- Rakefile
|
100
|
+
- VERSION
|
101
|
+
- lib/madmimi.rb
|
102
|
+
- madmimi.gemspec
|
103
|
+
- test/fixtures/lists.xml
|
104
|
+
- test/fixtures/promotions.xml
|
105
|
+
- test/fixtures/search.xml
|
106
|
+
- test/helper.rb
|
107
|
+
- test/test_madmimi.rb
|
108
|
+
has_rdoc: true
|
109
|
+
homepage: http://github.com/madmimi/madmimi-gem
|
110
|
+
licenses: []
|
111
|
+
|
112
|
+
post_install_message:
|
113
|
+
rdoc_options:
|
114
|
+
- --charset=UTF-8
|
115
|
+
require_paths:
|
116
|
+
- lib
|
117
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
118
|
+
none: false
|
119
|
+
requirements:
|
120
|
+
- - ">="
|
121
|
+
- !ruby/object:Gem::Version
|
122
|
+
hash: 3
|
123
|
+
segments:
|
124
|
+
- 0
|
125
|
+
version: "0"
|
126
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
127
|
+
none: false
|
128
|
+
requirements:
|
129
|
+
- - ">="
|
130
|
+
- !ruby/object:Gem::Version
|
131
|
+
hash: 3
|
132
|
+
segments:
|
133
|
+
- 0
|
134
|
+
version: "0"
|
135
|
+
requirements: []
|
136
|
+
|
137
|
+
rubyforge_project:
|
138
|
+
rubygems_version: 1.3.7
|
139
|
+
signing_key:
|
140
|
+
specification_version: 3
|
141
|
+
summary: Mad Mimi API wrapper for Ruby
|
142
|
+
test_files:
|
143
|
+
- test/helper.rb
|
144
|
+
- test/test_madmimi.rb
|