bgetting-hominid 1.1.1 → 1.1.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (4) hide show
  1. data/README.textile +5 -1
  2. data/VERSION.yml +1 -1
  3. data/lib/hominid.rb +16 -24
  4. metadata +2 -2
data/README.textile CHANGED
@@ -4,7 +4,7 @@ Hominid is a GemPlugin wrapper to the "Mailchimp API":http://www.mailchimp.com/a
4
4
 
5
5
  h2. Installation
6
6
 
7
- There are a few options for installing Hominid. Please note that Hominid expects to find a configuration file at @/config/hominid.yml@. If you are using Hominid as a GemPlugin, you will need to be sure and create this file. If you are using Hominid as a normal Rails plugin, this file will be created automatically when the plugin is installed.
7
+ There are a few options for installing Hominid.
8
8
 
9
9
  Install as a Rails plugin:
10
10
 
@@ -18,6 +18,10 @@ Use the GemPlugin:
18
18
 
19
19
  <pre><code>config.gem "bgetting-hominid", :lib => 'hominid', :source => "http://gems.github.com"</code></pre>
20
20
 
21
+ h2. Configuration
22
+
23
+ Please note that Hominid expects to find a configuration file at @/config/hominid.yml@. If you are using Hominid as a GemPlugin, you will need to be sure and create this file. If you are using Hominid as a normal Rails plugin, this file will be created automatically when the plugin is installed. You will need to create a Mailchimp account and put your API key (available at "http://admin.mailchimp.com/account/api/":http://admin.mailchimp.com/account/api/) into the configuration file.
24
+
21
25
  h2. Example
22
26
 
23
27
  To interact with the Mailchimp API, simply create a new Hominid object:
data/VERSION.yml CHANGED
@@ -1,4 +1,4 @@
1
1
  ---
2
2
  :major: 1
3
3
  :minor: 1
4
- :patch: 1
4
+ :patch: 2
data/lib/hominid.rb CHANGED
@@ -3,10 +3,11 @@ require 'xmlrpc/client'
3
3
  class Hominid
4
4
 
5
5
  # MailChimp API Documentation: http://www.mailchimp.com/api/1.2/
6
+ MAILCHIMP_API = "http://api.mailchimp.com/1.2/"
6
7
 
7
- def initialize(autologin = true)
8
+ def initialize
8
9
  load_monkey_brains
9
- login if autologin
10
+ @chimpApi ||= XMLRPC::Client.new2(MAILCHIMP_API)
10
11
  return self
11
12
  end
12
13
 
@@ -14,36 +15,27 @@ class Hominid
14
15
  config = YAML.load(File.open("#{RAILS_ROOT}/config/hominid.yml"))[RAILS_ENV].symbolize_keys
15
16
  @chimpUsername = config[:username].to_s
16
17
  @chimpPassword = config[:password].to_s
18
+ @api_key = config[:api_key]
17
19
  @send_goodbye = config[:send_goodbye]
18
20
  @send_notify = config[:send_notify]
19
21
  @double_opt = config[:double_opt]
20
22
  end
21
23
 
22
- def login
23
- begin
24
- @chimpApi ||= XMLRPC::Client.new2("http://api.mailchimp.com/1.2/")
25
- @api_key = @chimpApi.call("login", @chimpUsername, @chimpPassword)
26
- rescue
27
- puts "***** Mail Chimp Error *****"
28
- puts "Connection: #{@chimpApi}"
29
- puts "Login: #{@chimpUsername}"
30
- puts "Password: #{@chimpPassword}"
31
- end
32
- end
24
+ ## Security related methods
33
25
 
34
- def add_api_key(key)
26
+ def add_api_key
35
27
  begin
36
- @chimpApi ||= XMLRPC::Client.new2("http://api.mailchimp.com/1.2/")
37
- @chimpApi.call("apikeyAdd", @chimpUsername, @chimpPassword, key)
28
+ @chimpApi ||= XMLRPC::Client.new2(MAILCHIMP_API)
29
+ @chimpApi.call("apikeyAdd", @chimpUsername, @chimpPassword, @api_key)
38
30
  rescue
39
31
  false
40
32
  end
41
33
  end
42
34
 
43
- def expire_api_key(key)
35
+ def expire_api_key
44
36
  begin
45
- @chimpApi ||= XMLRPC::Client.new2("http://api.mailchimp.com/1.2/")
46
- @chimpApi.call("apikeyExpire", @chimpUsername, @chimpPassword, key)
37
+ @chimpApi ||= XMLRPC::Client.new2(MAILCHIMP_API)
38
+ @chimpApi.call("apikeyExpire", @chimpUsername, @chimpPassword, @api_key)
47
39
  rescue
48
40
  false
49
41
  end
@@ -51,7 +43,7 @@ class Hominid
51
43
 
52
44
  def api_keys(include_expired = false)
53
45
  begin
54
- @chimpApi ||= XMLRPC::Client.new2("http://api.mailchimp.com/1.2/")
46
+ @chimpApi ||= XMLRPC::Client.new2(MAILCHIMP_API)
55
47
  @api_keys = @chimpApi.call("apikeys", @chimpUsername, @chimpPassword, @api_key, include_expired)
56
48
  rescue
57
49
  return nil
@@ -207,7 +199,7 @@ class Hominid
207
199
  def create_group(list_id, group)
208
200
  # Add an interest group to a list
209
201
  begin
210
- @chimpApi.call("listInterestGroupAdd", @api_key, group)
202
+ @chimpApi.call("listInterestGroupAdd", @api_key, list_id, group)
211
203
  rescue
212
204
  false
213
205
  end
@@ -216,7 +208,7 @@ class Hominid
216
208
  def create_tag(list_id, tag, name, required = false)
217
209
  # Add a merge tag to a list
218
210
  begin
219
- @chimpApi.call("listMergeVarAdd", @api_key, tag, name, required)
211
+ @chimpApi.call("listMergeVarAdd", @api_key, list_id, tag, name, required)
220
212
  rescue
221
213
  false
222
214
  end
@@ -225,7 +217,7 @@ class Hominid
225
217
  def delete_group(list_id, group)
226
218
  # Delete an interest group for a list
227
219
  begin
228
- @chimpApi.call("listInterestGroupDel", @api_key, group)
220
+ @chimpApi.call("listInterestGroupDel", @api_key, list_id, group)
229
221
  rescue
230
222
  false
231
223
  end
@@ -234,7 +226,7 @@ class Hominid
234
226
  def delete_tag(list_id, tag)
235
227
  # Delete a merge tag and all its members
236
228
  begin
237
- @chimpApi.call("listMergeVarDel", @api_key, tag)
229
+ @chimpApi.call("listMergeVarDel", @api_key, list_id, tag)
238
230
  rescue
239
231
  false
240
232
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bgetting-hominid
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.1
4
+ version: 1.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Brian Getting
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2009-04-08 00:00:00 -07:00
12
+ date: 2009-05-28 00:00:00 -07:00
13
13
  default_executable:
14
14
  dependencies: []
15
15