Class: MailchimpSyncJob
- Inherits:
-
Struct
- Object
- Struct
- MailchimpSyncJob
- Defined in:
- app/models/job/mailchimp_sync_job.rb
Instance Attribute Summary collapse
-
#mailchimp_kit ⇒ Object
Returns the value of attribute mailchimp_kit.
-
#options ⇒ Object
Returns the value of attribute options.
Class Method Summary collapse
Instance Method Summary collapse
- #initial_sync ⇒ Object
- #kit_cancelled ⇒ Object
- #list_removal ⇒ Object
- #merged_person ⇒ Object
- #perform ⇒ Object
- #person_update_to_mailchimp ⇒ Object
- #webhook_campaign ⇒ Object
- #webhook_cleaned ⇒ Object
- #webhook_profile ⇒ Object
- #webhook_subscribe ⇒ Object
- #webhook_unsubscribe ⇒ Object
- #webhook_upemail ⇒ Object
Instance Attribute Details
#mailchimp_kit ⇒ Object
Returns the value of attribute mailchimp_kit
1 2 3 |
# File 'app/models/job/mailchimp_sync_job.rb', line 1 def mailchimp_kit @mailchimp_kit end |
#options ⇒ Object
Returns the value of attribute options
1 2 3 |
# File 'app/models/job/mailchimp_sync_job.rb', line 1 def @options end |
Class Method Details
.merged_person(kit, loser_email, winner_id, new_lists) ⇒ Object
2 3 4 5 6 7 8 9 10 11 |
# File 'app/models/job/mailchimp_sync_job.rb', line 2 def self.merged_person(kit, loser_email, winner_id, new_lists) return if kit.cancelled? job = new(kit, { :type => "merged_person", :loser_email => loser_email, :winner_id => winner_id, :new_lists => new_lists }) Delayed::Job.enqueue(job, :queue => "mailchimp") end |
Instance Method Details
#initial_sync ⇒ Object
17 18 19 20 21 22 23 24 |
# File 'app/models/job/mailchimp_sync_job.rb', line 17 def initial_sync list_ids.each do |list_id| mailchimp_kit.create_webhooks(list_id) mailchimp_kit.sync_mailchimp_to_artfully_update_members(list_id) mailchimp_kit.sync_mailchimp_to_artfully_new_members(list_id) end ProducerMailer.mailchimp_kit_initial_sync_notification(mailchimp_kit, mailchimp_kit.organization.owner, added_list_names, removed_list_names).deliver end |
#kit_cancelled ⇒ Object
64 65 66 67 68 69 70 71 72 73 |
# File 'app/models/job/mailchimp_sync_job.rb', line 64 def kit_cancelled mailchimp_kit.attached_lists.each do |list| mailchimp_kit.destroy_webhooks(list[:list_id]) end mailchimp_kit.organization.people.each do |person| person.subscribed_lists = [] person.save! end end |
#list_removal ⇒ Object
26 27 28 29 |
# File 'app/models/job/mailchimp_sync_job.rb', line 26 def list_removal mailchimp_kit.destroy_webhooks(list_id) mailchimp_kit.unsubscribe_old_members(list_id) end |
#merged_person ⇒ Object
31 32 33 34 |
# File 'app/models/job/mailchimp_sync_job.rb', line 31 def merged_person mailchimp_kit.sync_merged_loser_to_mailchimp([:loser_email]) mailchimp_kit.sync_merged_winner_to_mailchimp([:winner_id], [:new_lists]) end |
#perform ⇒ Object
13 14 15 |
# File 'app/models/job/mailchimp_sync_job.rb', line 13 def perform send([:type]) end |
#person_update_to_mailchimp ⇒ Object
60 61 62 |
# File 'app/models/job/mailchimp_sync_job.rb', line 60 def person_update_to_mailchimp mailchimp_kit.sync_artfully_person_update([:person_id], [:person_changes]) end |
#webhook_campaign ⇒ Object
56 57 58 |
# File 'app/models/job/mailchimp_sync_job.rb', line 56 def webhook_campaign mailchimp_kit.sync_mailchimp_webhook_campaign_sent(list_id, data) end |
#webhook_cleaned ⇒ Object
36 37 38 |
# File 'app/models/job/mailchimp_sync_job.rb', line 36 def webhook_cleaned mailchimp_kit.sync_mailchimp_webhook_cleaned(list_id, data) end |
#webhook_profile ⇒ Object
44 45 46 |
# File 'app/models/job/mailchimp_sync_job.rb', line 44 def webhook_profile mailchimp_kit.sync_mailchimp_webhook_update_person(list_id, data) end |
#webhook_subscribe ⇒ Object
40 41 42 |
# File 'app/models/job/mailchimp_sync_job.rb', line 40 def webhook_subscribe mailchimp_kit.sync_mailchimp_webhook_new_subscriber(list_id, data) end |
#webhook_unsubscribe ⇒ Object
52 53 54 |
# File 'app/models/job/mailchimp_sync_job.rb', line 52 def webhook_unsubscribe mailchimp_kit.sync_mailchimp_webhook_member_unsubscribe(list_id, data) end |
#webhook_upemail ⇒ Object
48 49 50 |
# File 'app/models/job/mailchimp_sync_job.rb', line 48 def webhook_upemail mailchimp_kit.sync_mailchimp_webhook_update_person_email(list_id, data) end |