madmimi 1.0.13 → 1.0.14

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/README.rdoc CHANGED
@@ -59,6 +59,10 @@ plain_text = "Plain text email contents [[unsubscribe]]"
59
59
 
60
60
  mimi.send_plaintext(options, plain_text)
61
61
 
62
+ === Getting the status of a transactional mailing
63
+
64
+ mimi.status('transaction_id') -> get the status on a specific transactional mailing
65
+
62
66
  === Return values
63
67
 
64
68
  In most cases, a return value of a single space indicates success.
@@ -92,6 +96,7 @@ will be those for an already-existing "audience."
92
96
 
93
97
  == Contributors
94
98
  tuker
99
+ marcheiligers
95
100
 
96
101
  == Copyright
97
102
 
data/Rakefile CHANGED
@@ -10,10 +10,10 @@ begin
10
10
  gem.email = "nicholas@madmimi.com"
11
11
  gem.homepage = "http://github.com/madmimi/madmimi-gem"
12
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"
13
+ gem.add_dependency "crack", ">0.1.7"
14
+ gem.add_development_dependency "jeweler", ">1.4"
15
+ gem.add_development_dependency "fakeweb", ">1.2"
16
+ gem.add_development_dependency "shoulda", ">2.10"
17
17
  # gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings
18
18
  end
19
19
  Jeweler::GemcutterTasks.new
data/VERSION CHANGED
@@ -1 +1 @@
1
- 1.0.13
1
+ 1.0.14
data/lib/madmimi.rb CHANGED
@@ -48,6 +48,7 @@ class MadMimi
48
48
  SEARCH_PATH = '/audience_members/search.xml'
49
49
  MAILER_PATH = '/mailer'
50
50
  MAILER_TO_LIST_PATH = '/mailer/to_list'
51
+ MAILER_STATUS_PATH = '/mailers/status'
51
52
 
52
53
  def initialize(username, api_key)
53
54
  @api_settings = { :username => username, :api_key => api_key }
@@ -172,6 +173,10 @@ class MadMimi
172
173
  do_request(MAILER_PATH, :post, options, true)
173
174
  end
174
175
  end
176
+
177
+ def status(transaction_id)
178
+ do_request "#{MAILER_STATUS_PATH}/#{transaction_id}", :get, {}, true
179
+ end
175
180
 
176
181
  private
177
182
 
@@ -180,10 +185,19 @@ class MadMimi
180
185
  options = options.merge(default_opt)
181
186
  form_data = options.inject({}) { |m, (k, v)| m[k.to_s] = v; m }
182
187
  resp = href = ""
188
+
189
+ if transactional == true
190
+ http = Net::HTTP.new(BASE_URL, 443)
191
+ http.use_ssl = true
192
+ http.verify_mode = OpenSSL::SSL::VERIFY_NONE
193
+ else
194
+ http = Net::HTTP.new(BASE_URL, 80)
195
+ end
196
+
183
197
  case req_type
198
+
184
199
  when :get then
185
200
  begin
186
- http = Net::HTTP.new(BASE_URL, 80)
187
201
  http.start do |http|
188
202
  req = Net::HTTP::Get.new(path)
189
203
  req.set_form_data(form_data)
@@ -196,13 +210,6 @@ class MadMimi
196
210
  end
197
211
  when :post then
198
212
  begin
199
- if transactional == true
200
- http = Net::HTTP.new(BASE_URL, 443)
201
- http.use_ssl = true
202
- http.verify_mode = OpenSSL::SSL::VERIFY_NONE
203
- else
204
- http = Net::HTTP.new(BASE_URL, 80)
205
- end
206
213
  http.start do |http|
207
214
  req = Net::HTTP::Post.new(path)
208
215
  req.set_form_data(form_data)
data/madmimi.gemspec CHANGED
@@ -1,43 +1,41 @@
1
1
  # Generated by jeweler
2
2
  # DO NOT EDIT THIS FILE DIRECTLY
3
- # Instead, edit Jeweler::Tasks in Rakefile, and run the gemspec command
3
+ # Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
4
4
  # -*- encoding: utf-8 -*-
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{madmimi}
8
- s.version = "1.0.13"
8
+ s.version = "1.0.14"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Nicholas Young", "Marc Heiligers"]
12
- s.date = %q{2010-07-21}
12
+ s.date = %q{2011-03-18}
13
13
  s.description = %q{Send emails, track statistics, and manage your subscriber base with ease.}
14
14
  s.email = %q{nicholas@madmimi.com}
15
15
  s.extra_rdoc_files = [
16
16
  "LICENSE",
17
- "README.rdoc"
17
+ "README.rdoc"
18
18
  ]
19
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"
20
+ "LICENSE",
21
+ "README.rdoc",
22
+ "Rakefile",
23
+ "VERSION",
24
+ "lib/madmimi.rb",
25
+ "madmimi.gemspec",
26
+ "test/fixtures/lists.xml",
27
+ "test/fixtures/promotions.xml",
28
+ "test/fixtures/search.xml",
29
+ "test/helper.rb",
30
+ "test/test_madmimi.rb"
32
31
  ]
33
32
  s.homepage = %q{http://github.com/madmimi/madmimi-gem}
34
- s.rdoc_options = ["--charset=UTF-8"]
35
33
  s.require_paths = ["lib"]
36
34
  s.rubygems_version = %q{1.3.7}
37
35
  s.summary = %q{Mad Mimi API wrapper for Ruby}
38
36
  s.test_files = [
39
37
  "test/helper.rb",
40
- "test/test_madmimi.rb"
38
+ "test/test_madmimi.rb"
41
39
  ]
42
40
 
43
41
  if s.respond_to? :specification_version then
@@ -45,21 +43,21 @@ Gem::Specification.new do |s|
45
43
  s.specification_version = 3
46
44
 
47
45
  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"])
46
+ s.add_runtime_dependency(%q<crack>, ["> 0.1.7"])
47
+ s.add_development_dependency(%q<jeweler>, ["> 1.4"])
48
+ s.add_development_dependency(%q<fakeweb>, ["> 1.2"])
49
+ s.add_development_dependency(%q<shoulda>, ["> 2.10"])
52
50
  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"])
51
+ s.add_dependency(%q<crack>, ["> 0.1.7"])
52
+ s.add_dependency(%q<jeweler>, ["> 1.4"])
53
+ s.add_dependency(%q<fakeweb>, ["> 1.2"])
54
+ s.add_dependency(%q<shoulda>, ["> 2.10"])
57
55
  end
58
56
  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"])
57
+ s.add_dependency(%q<crack>, ["> 0.1.7"])
58
+ s.add_dependency(%q<jeweler>, ["> 1.4"])
59
+ s.add_dependency(%q<fakeweb>, ["> 1.2"])
60
+ s.add_dependency(%q<shoulda>, ["> 2.10"])
63
61
  end
64
62
  end
65
63
 
data/test/helper.rb CHANGED
@@ -17,22 +17,27 @@ def fixture_file(filename)
17
17
  end
18
18
 
19
19
  def madmimi_url(url, https = false)
20
- if https = false
21
- url =~ /^http/ ? url : "http://api.madmimi.com#{url}"
22
- else
20
+ if https
23
21
  url =~ /^https/ ? url : "https://api.madmimi.com#{url}"
22
+ else
23
+ url =~ /^http/ ? url : "http://api.madmimi.com#{url}"
24
24
  end
25
25
  end
26
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)
27
+ def stub_get(url, options = {})
28
+ https = options.delete(:https)
29
+
30
+ filename = options.delete(:filename)
31
+ options = { :body => fixture_file(filename) } if filename
32
+
33
+ FakeWeb.register_uri(:get, madmimi_url(url, https), options)
31
34
  end
32
35
 
33
- # In the process of tweaking this. - Nicholas
34
36
  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)
37
+ https = options.delete(:https)
38
+
39
+ filename = options.delete(:filename)
40
+ options = { :body => fixture_file(filename) } if filename
41
+
42
+ FakeWeb.register_uri(:post, madmimi_url(url, https), options)
38
43
  end
data/test/test_madmimi.rb CHANGED
@@ -1,27 +1,33 @@
1
1
  require 'helper'
2
2
 
3
3
  class TestMadmimi < Test::Unit::TestCase
4
- context "A API call" do
4
+ context "An API call" do
5
5
  setup do
6
6
  @mimi = MadMimi.new('email@example.com', 'testapikey')
7
7
  end
8
8
 
9
9
  should "retrieve a hash of promotions" do
10
- stub_get('/promotions.xml', 'promotions.xml')
10
+ stub_get('/promotions.xml', { :filename => 'promotions.xml'})
11
11
  response = @mimi.promotions
12
12
  flunk "I couldn't find any promotions." unless response.kind_of?(Hash) || !response.empty?
13
13
  end
14
14
 
15
15
  should "retrieve a hash of lists" do
16
- stub_get('/audience_lists/lists.xml', 'lists.xml')
16
+ stub_get('/audience_lists/lists.xml', { :filename => 'lists.xml'})
17
17
  response = @mimi.lists
18
18
  flunk "Doesn't return any lists." unless response.kind_of?(Hash) || !response.empty?
19
19
  end
20
20
 
21
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')
22
+ stub_get('/audience_members/search.xml?query=nicholas', { :filename => 'search.xml'})
23
23
  response = @mimi.audience_search('nicholas')
24
24
  flunk "No users found." unless response.kind_of?(Hash) || !response.empty?
25
25
  end
26
+
27
+ should "get a transactional mailing status" do
28
+ stub_get('/mailers/status/1234', { :https => true, :body => "sent" })
29
+ response = @mimi.status(1234)
30
+ assert_equal "sent", response
31
+ end
26
32
  end
27
33
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: madmimi
3
3
  version: !ruby/object:Gem::Version
4
- hash: 13
4
+ hash: 11
5
5
  prerelease: false
6
6
  segments:
7
7
  - 1
8
8
  - 0
9
- - 13
10
- version: 1.0.13
9
+ - 14
10
+ version: 1.0.14
11
11
  platform: ruby
12
12
  authors:
13
13
  - Nicholas Young
@@ -16,7 +16,7 @@ autorequire:
16
16
  bindir: bin
17
17
  cert_chain: []
18
18
 
19
- date: 2010-07-21 00:00:00 -05:00
19
+ date: 2011-03-18 00:00:00 +02:00
20
20
  default_executable:
21
21
  dependencies:
22
22
  - !ruby/object:Gem::Dependency
@@ -25,7 +25,7 @@ dependencies:
25
25
  requirement: &id001 !ruby/object:Gem::Requirement
26
26
  none: false
27
27
  requirements:
28
- - - "="
28
+ - - ">"
29
29
  - !ruby/object:Gem::Version
30
30
  hash: 21
31
31
  segments:
@@ -41,14 +41,13 @@ dependencies:
41
41
  requirement: &id002 !ruby/object:Gem::Requirement
42
42
  none: false
43
43
  requirements:
44
- - - "="
44
+ - - ">"
45
45
  - !ruby/object:Gem::Version
46
46
  hash: 7
47
47
  segments:
48
48
  - 1
49
49
  - 4
50
- - 0
51
- version: 1.4.0
50
+ version: "1.4"
52
51
  type: :development
53
52
  version_requirements: *id002
54
53
  - !ruby/object:Gem::Dependency
@@ -57,14 +56,13 @@ dependencies:
57
56
  requirement: &id003 !ruby/object:Gem::Requirement
58
57
  none: false
59
58
  requirements:
60
- - - "="
59
+ - - ">"
61
60
  - !ruby/object:Gem::Version
62
- hash: 15
61
+ hash: 11
63
62
  segments:
64
63
  - 1
65
64
  - 2
66
- - 8
67
- version: 1.2.8
65
+ version: "1.2"
68
66
  type: :development
69
67
  version_requirements: *id003
70
68
  - !ruby/object:Gem::Dependency
@@ -73,14 +71,13 @@ dependencies:
73
71
  requirement: &id004 !ruby/object:Gem::Requirement
74
72
  none: false
75
73
  requirements:
76
- - - "="
74
+ - - ">"
77
75
  - !ruby/object:Gem::Version
78
- hash: 33
76
+ hash: 23
79
77
  segments:
80
78
  - 2
81
79
  - 10
82
- - 3
83
- version: 2.10.3
80
+ version: "2.10"
84
81
  type: :development
85
82
  version_requirements: *id004
86
83
  description: Send emails, track statistics, and manage your subscriber base with ease.
@@ -93,7 +90,6 @@ extra_rdoc_files:
93
90
  - LICENSE
94
91
  - README.rdoc
95
92
  files:
96
- - .gitignore
97
93
  - LICENSE
98
94
  - README.rdoc
99
95
  - Rakefile
@@ -110,8 +106,8 @@ homepage: http://github.com/madmimi/madmimi-gem
110
106
  licenses: []
111
107
 
112
108
  post_install_message:
113
- rdoc_options:
114
- - --charset=UTF-8
109
+ rdoc_options: []
110
+
115
111
  require_paths:
116
112
  - lib
117
113
  required_ruby_version: !ruby/object:Gem::Requirement
data/.gitignore DELETED
@@ -1,3 +0,0 @@
1
- pkg
2
- *.gem
3
- tags