Class: Chimpmunk::EmailList

Inherits:
ActiveRecord::Base
  • Object
show all
Defined in:
lib/chimpmunk/email_list.rb

Class Method Summary collapse

Class Method Details

.refresh_email_listsObject

refresh email lists



23
24
25
26
27
28
29
30
31
32
33
34
35
36
# File 'lib/chimpmunk/email_list.rb', line 23

def self.refresh_email_lists
  lists = Chimpmunk.mailchimp.lists.list
  lists['data'].each do |list|
    next if Chimpmunk::EmailList.where(mailchimp_id: list['id']).first

    Chimpmunk::EmailList.create(
      mailchimp_id: list['id'],
      name: list['name'],
      default_from_name: list['default_from_name'],
      default_from_email: list['default_from_email'],
      default_subject: list['default_subject']  
    )
  end
end