bcaccinolo-mailchimp_api 0.0.4 → 0.0.5

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 CHANGED
@@ -1,6 +1,24 @@
1
1
  Mailchimp API
2
2
  ============
3
- Author: Benoit Caccinolo
3
+
4
+ A simple gem to connect with the MailChimp API 1.2
5
+
6
+ Author
7
+ ======
8
+ Benoit Caccinolo (benoit.caccinolo@gmail.com)
9
+
10
+ Installation
11
+ ============
12
+
13
+ gem sources -a http://gems.github.com (you only have to do this once
14
+ gem install bcaccinolo-mailchimp_api
15
+
16
+
17
+ Run the unit tests
18
+ ==================
19
+
20
+ rake test
21
+
4
22
 
5
23
 
6
24
 
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.0.4
1
+ 0.0.5
@@ -24,10 +24,10 @@ class MailChimp
24
24
  end
25
25
 
26
26
  # tested
27
- def campaign_create list_id, from_email, from_name, subject, content
27
+ def campaign_create list_id, from_email, from_name, subject, content, generate_text = true
28
28
  params = {:options => {:list_id => list_id, :subject => subject,
29
29
  :from_name => from_name, :from_email => from_email},
30
- :type => "regular", :content => {"html" => content} }
30
+ :type => "regular", :content => content, :generate_text => generate_text}
31
31
  ret = call_server 'campaignCreate', params
32
32
  if ret.class == String
33
33
  ret = ret.slice(1, ret.size-2)
@@ -111,7 +111,7 @@ class MailChimp
111
111
  path = "/1.1/?output=json&method=#{method}"
112
112
  params[:apikey] = @api unless method == "login"
113
113
  data = gen_params_list(params)
114
- #puts "http://#{url}#{path}&#{data}"
114
+ #puts ">>> http://#{url}#{path}&#{data}"
115
115
  http = Net::HTTP.new(url)
116
116
  result = http.post(path, data)
117
117
  begin
@@ -126,14 +126,14 @@ class MailChimp
126
126
  params.map do |key, value|
127
127
  if value.class == Hash
128
128
  value.map do |k, v|
129
- "#{key}[#{k}]=#{v}"
129
+ "#{key}[#{k}]=#{CGI::escape(v.to_s)}"
130
130
  end.join '&'
131
131
  elsif value.class == Array
132
132
  value.map do |v|
133
- "#{key}[]=#{v}"
133
+ "#{key}[]=#{CGI::escape(vi.to_s)}"
134
134
  end.join '&'
135
135
  else
136
- "#{key}=#{value}"
136
+ "#{key}=#{CGI::escape(value.to_s)}"
137
137
  end
138
138
  end.join '&'
139
139
  end
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{mailchimp_api}
8
- s.version = "0.0.4"
8
+ s.version = "0.0.5"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Benoit Caccinolo"]
12
- s.date = %q{2009-08-11}
12
+ s.date = %q{2009-09-23}
13
13
  s.description = %q{TODO}
14
14
  s.email = %q{benoit.caccinolo@gmail.com}
15
15
  s.extra_rdoc_files = [
@@ -26,7 +26,7 @@ Gem::Specification.new do |s|
26
26
  s.homepage = %q{http://ruready.tumblr.com}
27
27
  s.rdoc_options = ["--charset=UTF-8"]
28
28
  s.require_paths = ["lib"]
29
- s.rubygems_version = %q{1.3.4}
29
+ s.rubygems_version = %q{1.3.5}
30
30
  s.summary = %q{Summarize your gem}
31
31
  s.test_files = [
32
32
  "test/test_mc.rb"
@@ -1,8 +1,8 @@
1
1
  require "test/unit"
2
- require "lib/mailchimp"
2
+ require "lib/mailchimp_api"
3
3
 
4
4
  LOGIN=""
5
- PWD=""
5
+ PWD=""
6
6
 
7
7
  class TestMailChimp < Test::Unit::TestCase
8
8
 
@@ -22,9 +22,15 @@ class TestMailChimp < Test::Unit::TestCase
22
22
 
23
23
  #def teardown
24
24
  #end
25
+ #
26
+ def test_login
27
+ mc = MailChimp.new
28
+ ret = mc.login LOGIN, PWD
29
+ assert ret
30
+ end
25
31
 
26
32
  def test_ping
27
- ret = @mc.ping
33
+ ret = @@mc.ping
28
34
  assert ret == true
29
35
  end
30
36
 
@@ -42,22 +48,23 @@ class TestMailChimp < Test::Unit::TestCase
42
48
  end
43
49
 
44
50
  def test_list_subscribe
45
- assert @mc.list_subscribe(@list_id, "benoit_test@gmail.com")
51
+ assert @@mc.list_subscribe(@@list_id, "benoit_test@gmail.com")
46
52
  end
47
53
 
48
54
  def test_list_unsubscribe
49
- assert @mc.list_unsubscribe(@list_id, "benoit_test@gmail.com")
55
+ assert @@mc.list_unsubscribe(@@list_id, "benoit_test@gmail.com")
50
56
  end
51
57
 
52
58
  def test_list_batch_subscribe
53
- ret = @mc.list_batch_subscribe(@list_id, [ ["EMAIL" => "benoit_test4@gmail.com"] ])
54
- assert(ret["success_count"] == "1", ret.to_yaml)
59
+ ret = @@mc.list_batch_subscribe(@@list_id, [ {"EMAIL" => "benoit_test4@gmail.com"},
60
+ {"EMAIL" => "benoit_test5@gmail.com"}])
61
+ assert(ret["success_count"] == 2, ret.to_yaml)
55
62
  end
56
63
 
57
64
  def test_list_batch_unsubscribe
58
- @mc.list_subscribe(@list_id, "benoit_test1@gmail.com")
59
- @mc.list_subscribe(@list_id, "benoit_test2@gmail.com")
60
- ret = @mc.list_batch_unsubscribe(@list_id, ["benoit_test1@gmail.com", "benoit_test2@gmail.com"])
65
+ @@mc.list_subscribe(@@list_id, "benoit_test1@gmail.com")
66
+ @@mc.list_subscribe(@@list_id, "benoit_test2@gmail.com")
67
+ ret = @@mc.list_batch_unsubscribe(@@list_id, ["benoit_test1@gmail.com", "benoit_test2@gmail.com"])
61
68
  assert(ret["success_count"] == 2, ret.to_yaml)
62
69
  end
63
70
 
@@ -91,9 +98,8 @@ class TestMailChimp < Test::Unit::TestCase
91
98
  campaign_id = ret
92
99
 
93
100
  ret = @@mc.campaign_send_test(campaign_id, ["benoit.caccinolo@gmail.com"])
94
- puts ret
95
101
  assert ret
96
- @@mc.campaign_delete campaign_id
102
+ ret = @@mc.campaign_delete campaign_id
97
103
  end
98
104
 
99
105
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bcaccinolo-mailchimp_api
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.4
4
+ version: 0.0.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Benoit Caccinolo
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2009-08-11 00:00:00 -07:00
12
+ date: 2009-09-23 00:00:00 -07:00
13
13
  default_executable:
14
14
  dependencies: []
15
15