Switch from Hominid to Mailchimp #177

Merged
merged 3 commits into from Aug 31, 2013
View
@@ -6,7 +6,7 @@ gem 'json', '~> 1.7.7'
gem 'multi_xml', '>= 0.5.2'
gem 'pg', '0.16.0'
-gem 'hominid'
+gem 'mailchimp'
gem 'omniauth-oauth2', '~> 1.1.1'
gem 'omniauth-github', '~> 1.0.1'
View
@@ -108,7 +108,6 @@ GEM
hashie (1.2.0)
highline (1.6.15)
hike (1.2.1)
- hominid (3.0.2)
httparty (0.10.2)
multi_json (~> 1.0)
multi_xml (>= 0.5.2)
@@ -128,6 +127,8 @@ GEM
i18n (>= 0.4.0)
mime-types (~> 1.16)
treetop (~> 1.4.8)
+ mailchimp (0.0.9)
+ httparty
mailhopper (0.0.9)
rails (>= 3.1.0)
md_emoji (0.0.8)
@@ -295,11 +296,11 @@ DEPENDENCIES
factory_girl_rails
god
haml
- hominid
httparty (>= 0.10.0)
jquery-rails
json (~> 1.7.7)
launchy
+ mailchimp
mailhopper (~> 0.0.4)
md_emoji
md_preview
@@ -2,18 +2,21 @@ class UserManager
attr_reader :client, :list_id
def initialize
- @client = Hominid::API.new(MailChimp::SETTINGS[:api_key])
- @list_id = MailChimp::SETTINGS[:list_id]
+ @client = Mailchimp::API.new(MailChimpSettings[:api_key])
+ @client.throws_exceptions = true
+ @list_id = MailChimpSettings[:list_id]
end
def delete_user(email)
- client.list_unsubscribe(list_id, email, true)
+ client.list_unsubscribe(:id => list_id,
+ :email_address => email,
+ :delete_member => true)
AccountMailer.unsubscribed(email)
end
def unsubscribed_users
- client.list_members(list_id, "unsubscribed")["data"].map {|u| u["email"] }
+ client.list_members(:id => list_id, :status => "unsubscribed")["data"].map {|u| u["email"] }
end
def disable_unsubscribed_users
@@ -29,4 +32,4 @@ def disable_unsubscribed_users
delete_user(email)
end
end
-end
+end
@@ -1,8 +1,7 @@
-module MailChimp
- SETTINGS = { :list_id => 'YOUR-LIST-ID',
- :api_key => 'YOUR-API-KEY',
- :testers => ["your@email.com"],
- :sender_name => "Your Sender Name",
- :sender_email => "Your Sender Email",
- :webhook_key => "Your webhook key" }
-end
+MailChimpSettings = {
+ :list_id => 'YOUR-LIST-ID',
+ :api_key => 'YOUR-API-KEY',
+ :testers => ["your@email.com"],
+ :sender_name => "Your Sender Name",
+ :sender_email => "Your Sender Email",
+ :webhook_key => "Your webhook key" }
View
@@ -3,7 +3,7 @@
mount StripeEvent::Engine => STRIPE_WEBHOOK_PATH
- match "/hooks/#{MailChimp::SETTINGS[:webhook_key]}" => 'hooks#receive'
+ match "/hooks/#{MailChimpSettings[:webhook_key]}" => 'hooks#receive'
match '/articles/shared/:secret' => 'articles#shared', :as => "shared_article"
match '/subscribe' => 'home#subscribe', :as => 'subscribe'