Module: Jung::Drivers::Mailchimp::Campaign

Defined in:
lib/jung/drivers/mailchimp/campaign.rb

Instance Method Summary collapse

Instance Method Details

#allObject



48
49
50
# File 'lib/jung/drivers/mailchimp/campaign.rb', line 48

def all
  api.all_campaigns
end

#deleteObject



42
43
44
45
46
# File 'lib/jung/drivers/mailchimp/campaign.rb', line 42

def delete
  delete_static_segment &&
  api.campaign_delete(id) &&
  reset 
end

#deliverObject



26
27
28
# File 'lib/jung/drivers/mailchimp/campaign.rb', line 26

def deliver
  api.campaign_send_now(id) if save
end

#deliver_test(recipients) ⇒ Object



30
31
32
# File 'lib/jung/drivers/mailchimp/campaign.rb', line 30

def deliver_test(recipients)
  api.campaign_send_test(id, recipients) if save
end

#find(id) ⇒ Object



3
4
5
6
7
8
9
10
11
12
13
14
15
# File 'lib/jung/drivers/mailchimp/campaign.rb', line 3

def find(id)
  @id = id
  campaign = api.campaign id

  return false if !campaign

  campaign_content = api.campaign_content id
  
  @name = campaign["title"]
  @subject = campaign["subject"]
  @message = campaign_content
  @sender = Jung::Sender.new(campaign["from_name"], campaign["from_email"])
end

#saveObject



17
18
19
20
21
22
23
24
# File 'lib/jung/drivers/mailchimp/campaign.rb', line 17

def save
  # if sync_merge_vars &&
  if sync_members &&
     sync_campaign &&
     sync_static_segments
    @id
  end
end

#schedule(time) ⇒ Object



34
35
36
# File 'lib/jung/drivers/mailchimp/campaign.rb', line 34

def schedule time
  api.campaign_schedule(id, time) if save
end

#unscheduleObject



38
39
40
# File 'lib/jung/drivers/mailchimp/campaign.rb', line 38

def unschedule
  api.campaign_unschedule(id) if id
end