Class: Mailchimp::Campaigns

Inherits:
Object
  • Object
show all
Defined in:
lib/mailchimp/api.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(master) ⇒ Campaigns



1426
1427
1428
# File 'lib/mailchimp/api.rb', line 1426

def initialize(master)
    @master = master
end

Instance Attribute Details

#masterObject

Returns the value of attribute master.



1424
1425
1426
# File 'lib/mailchimp/api.rb', line 1424

def master
  @master
end

Instance Method Details

#content(cid, options = []) ⇒ Hash

Get the content (both html and text) for a campaign either as it would appear in the campaign archive or as the raw, original content



1441
1442
1443
1444
# File 'lib/mailchimp/api.rb', line 1441

def content(cid, options=[])
    _params = {:cid => cid, :options => options}
    return @master.call 'campaigns/content', _params
end

#create(type, options, content, segment_opts = nil, type_opts = nil) ⇒ Hash

Create a new draft campaign to send. You <strong>can not</strong> have more than 32,000 campaigns in your account.



1539
1540
1541
1542
# File 'lib/mailchimp/api.rb', line 1539

def create(type, options, content, segment_opts=nil, type_opts=nil)
    _params = {:type => type, :options => options, :content => content, :segment_opts => segment_opts, :type_opts => type_opts}
    return @master.call 'campaigns/create', _params
end

#delete(cid) ⇒ Hash

Delete a campaign. Seriously, “poof, gone!” - be careful! Seriously, no one can undelete these.



1548
1549
1550
1551
# File 'lib/mailchimp/api.rb', line 1548

def delete(cid)
    _params = {:cid => cid}
    return @master.call 'campaigns/delete', _params
end

#list(filters = [], start = 0, limit = 25, sort_field = 'create_time', sort_dir = 'DESC') ⇒ Hash

Get the list of campaigns and their details matching the specified filters



1632
1633
1634
1635
# File 'lib/mailchimp/api.rb', line 1632

def list(filters=[], start=0, limit=25, sort_field='create_time', sort_dir='DESC')
    _params = {:filters => filters, :start => start, :limit => limit, :sort_field => sort_field, :sort_dir => sort_dir}
    return @master.call 'campaigns/list', _params
end

#pause(cid) ⇒ Hash

Pause an AutoResponder or RSS campaign from sending



1641
1642
1643
1644
# File 'lib/mailchimp/api.rb', line 1641

def pause(cid)
    _params = {:cid => cid}
    return @master.call 'campaigns/pause', _params
end

#ready(cid) ⇒ Hash

Returns information on whether a campaign is ready to send and possible issues we may have detected with it - very similar to the confirmation step in the app.



1654
1655
1656
1657
# File 'lib/mailchimp/api.rb', line 1654

def ready(cid)
    _params = {:cid => cid}
    return @master.call 'campaigns/ready', _params
end

#replicate(cid) ⇒ Hash

Replicate a campaign.



1662
1663
1664
1665
# File 'lib/mailchimp/api.rb', line 1662

def replicate(cid)
    _params = {:cid => cid}
    return @master.call 'campaigns/replicate', _params
end

#resume(cid) ⇒ Hash

Resume sending an AutoResponder or RSS campaign



1671
1672
1673
1674
# File 'lib/mailchimp/api.rb', line 1671

def resume(cid)
    _params = {:cid => cid}
    return @master.call 'campaigns/resume', _params
end

#schedule(cid, schedule_time, schedule_time_b = nil) ⇒ Hash

Schedule a campaign to be sent in the future



1682
1683
1684
1685
# File 'lib/mailchimp/api.rb', line 1682

def schedule(cid, schedule_time, schedule_time_b=nil)
    _params = {:cid => cid, :schedule_time => schedule_time, :schedule_time_b => schedule_time_b}
    return @master.call 'campaigns/schedule', _params
end

#schedule_batch(cid, schedule_time, num_batches = 2, stagger_mins = 5) ⇒ Hash

Schedule a campaign to be sent in batches sometime in the future. Only valid for “regular” campaigns



1694
1695
1696
1697
# File 'lib/mailchimp/api.rb', line 1694

def schedule_batch(cid, schedule_time, num_batches=2, stagger_mins=5)
    _params = {:cid => cid, :schedule_time => schedule_time, :num_batches => num_batches, :stagger_mins => stagger_mins}
    return @master.call 'campaigns/schedule-batch', _params
end

#segment_test(list_id, options) ⇒ Hash

Allows one to test their segmentation rules before creating a campaign using them.



1707
1708
1709
1710
# File 'lib/mailchimp/api.rb', line 1707

def segment_test(list_id, options)
    _params = {:list_id => list_id, :options => options}
    return @master.call 'campaigns/segment-test', _params
end

#send(cid) ⇒ Hash

Send a given campaign immediately. For RSS campaigns, this will “start” them.



1716
1717
1718
1719
# File 'lib/mailchimp/api.rb', line 1716

def send(cid)
    _params = {:cid => cid}
    return @master.call 'campaigns/send', _params
end

#send_test(cid, test_emails = [], send_type = 'html') ⇒ Hash

Send a test of this campaign to the provided email addresses



1727
1728
1729
1730
# File 'lib/mailchimp/api.rb', line 1727

def send_test(cid, test_emails=[], send_type='html')
    _params = {:cid => cid, :test_emails => test_emails, :send_type => send_type}
    return @master.call 'campaigns/send-test', _params
end

#template_content(cid) ⇒ Hash

Get the HTML template content sections for a campaign. Note that this <strong>will</strong> return very jagged, non-standard results based on the template a campaign is using. You only want to use this if you want to allow editing template sections in your application.



1735
1736
1737
1738
# File 'lib/mailchimp/api.rb', line 1735

def template_content(cid)
    _params = {:cid => cid}
    return @master.call 'campaigns/template-content', _params
end

#unschedule(cid) ⇒ Hash

Unschedule a campaign that is scheduled to be sent in the future



1744
1745
1746
1747
# File 'lib/mailchimp/api.rb', line 1744

def unschedule(cid)
    _params = {:cid => cid}
    return @master.call 'campaigns/unschedule', _params
end

#update(cid, name, value) ⇒ Hash

Update just about any setting besides type for a campaign that has not been sent. See campaigns/create() for details. Caveats:<br/><ul class=‘bullets’> <li>If you set a new list_id, all segmentation options will be deleted and must be re-added.</li> <li>If you set template_id, you need to follow that up by setting it’s ‘content’</li> <li>If you set segment_opts, you should have tested your options against campaigns/segment-test().</li> <li>To clear/unset segment_opts, pass an empty string or array as the value. Various wrappers may require one or the other.</li> </ul>



1759
1760
1761
1762
# File 'lib/mailchimp/api.rb', line 1759

def update(cid, name, value)
    _params = {:cid => cid, :name => name, :value => value}
    return @master.call 'campaigns/update', _params
end