interface to import mails automatically
This commit is contained in:
@@ -44,6 +44,8 @@ gem 'rails_admin'
|
||||
|
||||
gem 'mongoid_paranoia'
|
||||
|
||||
gem 'mailchimp-api', require: 'mailchimp'
|
||||
|
||||
group :development, :test do
|
||||
# Call 'byebug' anywhere in the code to stop execution and get a debugger console
|
||||
gem 'byebug'
|
||||
@@ -58,5 +60,5 @@ group :development do
|
||||
gem 'web-console', '~> 2.0'
|
||||
|
||||
# Spring speeds up development by keeping your application running in the background. Read more: https://github.com/rails/spring
|
||||
gem 'spring'
|
||||
# gem 'spring'
|
||||
end
|
||||
|
||||
+5
-2
@@ -67,6 +67,7 @@ GEM
|
||||
debug_inspector (0.0.2)
|
||||
diff-lcs (1.2.5)
|
||||
erubis (2.7.0)
|
||||
excon (0.49.0)
|
||||
execjs (2.6.0)
|
||||
font-awesome-rails (4.6.1.0)
|
||||
railties (>= 3.2, < 5.1)
|
||||
@@ -93,6 +94,9 @@ GEM
|
||||
nokogiri (>= 1.5.9)
|
||||
mail (2.6.4)
|
||||
mime-types (>= 1.16, < 4)
|
||||
mailchimp-api (2.0.6)
|
||||
excon (>= 0.16.0)
|
||||
json (>= 1.7.7)
|
||||
method_source (0.8.2)
|
||||
mime-types (3.0)
|
||||
mime-types-data (~> 3.2015)
|
||||
@@ -229,7 +233,6 @@ GEM
|
||||
railties (>= 3.1, < 5.0)
|
||||
slim (~> 3.0)
|
||||
slop (3.6.0)
|
||||
spring (1.6.4)
|
||||
sprockets (3.5.2)
|
||||
concurrent-ruby (~> 1.0)
|
||||
rack (> 1, < 3)
|
||||
@@ -266,6 +269,7 @@ DEPENDENCIES
|
||||
geocoder
|
||||
jbuilder (~> 2.0)
|
||||
jquery-rails
|
||||
mailchimp-api
|
||||
mongoid (~> 5.0.0)
|
||||
mongoid-rspec (= 3.0.0)
|
||||
mongoid_paranoia
|
||||
@@ -281,7 +285,6 @@ DEPENDENCIES
|
||||
simple_form
|
||||
slim
|
||||
slim-rails
|
||||
spring
|
||||
turbolinks
|
||||
uglifier (>= 1.3.0)
|
||||
web-console (~> 2.0)
|
||||
|
||||
@@ -0,0 +1,25 @@
|
||||
class MailChimpBatchUpdate
|
||||
def self.update_all(api_key, list_id)
|
||||
subscribers = []
|
||||
Supporter.each do |supporter|
|
||||
subscriber = {
|
||||
'EMAIL' => { 'email' => supporter.email },
|
||||
'language' => supporter.language,
|
||||
:EMAIL_TYPE => 'html',
|
||||
:merge_vars => {
|
||||
'EMAIL' => supporter.email,
|
||||
'FNAME' => supporter.first_name,
|
||||
'LNAME' => supporter.last_name,
|
||||
'SUPPORT' => supporter.support,
|
||||
'MEMBERSHIP' => supporter.li_membership.to_s,
|
||||
'AGE' => supporter.age_category,
|
||||
'LANG' => supporter.language
|
||||
}
|
||||
}
|
||||
subscribers.push(subscriber)
|
||||
end
|
||||
|
||||
mailchimp = Mailchimp::API.new(api_key)
|
||||
mailchimp.lists.batch_subscribe(list_id, subscribers, false, true, false)
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user